- Adding Custom CSS Classes to WPForms
- What’s a CSS Class?
- Adding Custom CSS Classes in WPForms
- Adding CSS Classes to Individual Form Fields
- Adding CSS Classes to a Form Container or Submit Button
- Creating and Adding CSS Styles for Your Site
- Creating CSS Styles
- Adding CSS to Your WordPress Site
- Custom CSS on a class
- Custom CSS on a class
- Append content via multiple CSS :after classes
- What is a CSS Class
- What is a CSS class
- How to create a CSS class
- How to use multiple classes on single HTMLtag
- How to use classes in HTML
- Conclusion
Adding Custom CSS Classes to WPForms
Would you like to customize the appearance of your WordPress forms? In WPForms, you can easily add custom CSS classes and styles to make your forms look how you’d like.
This tutorial will show you how to add custom CSS classes to style specific form elements, as well as how to add any custom CSS to your WordPress site.
Note: If you’re new to CSS, our beginner’s guide to styling forms with CSS is the best place to get started.
What’s a CSS Class?
CSS classes are a way of targeting the elements that you’d like to style on your website.
In WPForms, fields are automatically assigned several CSS classes. For instance, if a field is set to a Field Size of Large, it will be assigned the CSS class wpforms-field-large .
By adding a custom CSS class, you can easily target a specific form field or apply the same styles to multiple fields.
Note: If you’d like to style your forms but skip using custom CSS classes or writing any code, consider checking out our form styling tutorial.
Adding Custom CSS Classes in WPForms
In WPForms, you can add your own custom CSS classes to individual form fields, the submit button or the container around your form.
Adding CSS Classes to Individual Form Fields
To add a custom CSS class to a form field, you’ll need to create a new form or edit an existing form.
Within the form builder’s preview panel, click on the field to open its Field Options. Then, open the Advanced tab and look for the field labeled CSS Classes.
When naming a CSS class, you may use only letters or numbers, and no spaces are allowed. Class names are case-sensitive, so it is recommended that you use lowercase letters. If you’d like the class name to contain more than one word, include a hyphen (-) or underscore (_) instead of a space.
To avoid running into any issues, always start your class names with a letter.
For this example, we’ll name our CSS class wpf-blue-background .
By adding wpf- to the beginning of our classes, we’re less likely to add a class name already being used by our site’s theme. This will help to avoid style conflicts and make it more likely for our styles to be applied successfully.
When you’re ready, add the wpf-blue-background CSS class to the CSS Classes field.
If you’d like, you can also add additional classes to this field. To do that, simply add a space between each class name. For example:
wpf-blue-background wpf-bold-font wpf-xl-margin
Note: The CSS Classes field can also be used to display form fields in a multi-column layout and as a single-column layout on mobile.
Adding CSS Classes to a Form Container or Submit Button
For some styles, it may be useful to target the form’s container or its submit button.
For example, you may want the submit buttons for all signup forms on your site to be styled one way, and for the submit buttons in any general contact forms to be styled a different way. An easy way to accomplish this is by adding the same CSS class to any submit buttons that you’d like to be styled the same way.
To add a custom CSS class name for either option, open the form builder and go to Settings » General. From here, go to the Advanced section and you’ll be able to see fields for Form CSS Class and Submit Button CSS Class.
If you’d like to add more than one class name, just separate each with a space.
Note: If you’d like to, you can use a built-in form CSS class to display your form on a single line.
Creating and Adding CSS Styles for Your Site
Now that you’ve added a custom CSS class to a field in your form, you can create the styles you’d like applied.
Creating CSS Styles
CSS is a powerful tool with an extensive amount of styling options available. For instructions on how to get started with creating CSS, please see our Beginner’s CSS Guide.
For our example, we’ll simply add a blue background to any field with the class wpf-blue-background . When targeting a class name within CSS, it must always begin with a period (.), for example .wpf-blue-background .
Since many styles are already being applied to your form, it’s also a good idea to make your CSS more specific. To do that, simply add .wpforms-form in front of your custom class name.
.wpforms-form .wpf-blue-background
If your custom styles are not being applied successfully, you can include !important before the semicolon.
Note: Using !important is only necessary if your styles are not being applied otherwise. Our guide on troubleshooting CSS contains more details.
Adding CSS to Your WordPress Site
One quick and easy way to add custom CSS to your site is with the WordPress Theme Customizer. This is a popular option because it’s available in almost all themes and has a live preview area.
To access the CSS area of the Theme Customizer, go to Appearance » Customize and then select the tab labeled Additional CSS.
Next, go ahead and add your custom CSS snippet. When you’re ready, click Publish.
Here’s how our example form looks now with the CSS class and CSS styles applied:
Note: Are your custom styles not displaying? Please check out our guide to troubleshooting CSS for the most common issues and solutions.
That’s it! You can now add custom CSS classes to style specific areas of your forms.
Would you also like to view and modify our built-in form styles? Check out our tutorial on customizing individual form fields for all the details.
Custom CSS on a class
Keeping in view the importance of CSS class, this article aims to provide an insight into the CSS class with the following learning outcomes: What is a CSS class How to use multiple classes on a single Html tag CSS class for specific HTML tag What is a CSS class How to create a CSS class Primarily, the CSS class is used to enclose a set of CSS properties and then apply these properties by calling the class.
Custom CSS on a class
Links in the div #colophon will be white with the following code.
#colophon a:link #colophon a:visited #colophon a:hover #colophon a:active
This way lets you changed the color depending on the mouse and if is previously viewed. Having it change on hover helps the user know it is a link.
CSS .class Selector, To do this, start with the element name, then write the period (.) character, followed by the name of the class (look at Example 1 below). HTML elements can also refer to more than one class (look at Example 2 below). Version: CSS1 Browser Support CSS Syntax . class < css declarations; >Demo More Examples Example 1
Append content via multiple CSS :after classes
You’ll need additional rules for this to work.
Given that the ordering of classes matters (when normally it shouldn’t!), you’ll need to use attribute selectors instead of class selectors, and you’ll need to create two rules:
[class="required note"]:after < content: " *+"; color: red; >[class="note required"]:after
Simply add these rules after the ones you have and it should work, as attribute and class selectors are equally specific.
By the way, if you have common styles you can keep your code DRY by isolating them in another rule. For example, you can select each class and give them both color: red :
CSS Pseudo-classes, CSS — The :first-child Pseudo-class. The :first-child pseudo-class matches a specified element that is the first child of another element. Match the first
element. In the following example, the selector matches any
element that is the first child of any element:
What is a CSS Class
As we all know that Html and CSS go hand in hand in order to create a responsive and attractive website design but sometimes we need to apply the same CSS properties to multiple HTML tags according to the design requirement. Now the question arises, what do we do in such a situation? Here CSS classes came in to save us from writing the same CSS code multiple times.
CSS class is the key player in adding multiple properties to an element or the entire web page. Keeping in view the importance of CSS class, this article aims to provide an insight into the CSS class with the following learning outcomes:
- What is a CSS class
- How to use multiple classes on a single Html tag
- CSS class for specific HTML tag
What is a CSS class
In CSS, the class is used to define a set of properties to apply the CSS properties in bulk. A class can be used by multiple HTML tags at a time which means we do not need to write the same CSS properties in our HTML code multiple times just use class instead. A class is defined with the group of CSS properties. The general syntax of CSS class is provided below:
In CSS, a dot ( . ) is used to set a class name and CSS properties are then enclosed in curly braces.
How to create a CSS class
Primarily, the CSS class is used to enclose a set of CSS properties and then apply these properties by calling the class. The following code explains how CSS classes are created.
In the above example we create three CSS classes, container , center and color. These classes are applied on the , , and
tags respectively.
In the above output container class specifies the height and width of the container, also put a border while color class changes the font color and center class aligns the text to center.
How to use multiple classes on single HTMLtag
In CSS, we can use multiple classes on a single HTML tag which helps in styling HTML more efficiently. The following example demonstrates this concept better.
In the above code, five CSS classes are created. The container class is applied on the tag, whereas the rest of the four classes are applied on the
tags. Moreover, four different CSS classes are applied on a single
tag (last
In the above output the third paragraph is shown with application of multiple CSS classes at once.
How to use classes in HTML
We can also specify a CSS class for a specific HTML tag. This type of class is helpful when we want to apply the same styling on a specific tag everytime it is used. The following example helps you to understand better.
In this example, we created a color class specifically for tag and applied it on tag as well as
.
The above output clearly shows that color class only worked on tag because it is specifically created for tag.
Conclusion
In CSS, class is an attribute which is used to apply multiple CSS properties on HTML tags. A single CSS class can be applied on multiple HTML tags and vice versa. The dot ( . ) symbol identifies a CSS class. In this article, we have learned about css classes, how to use multiple css classes on single html tag and css class for specific HTMLtag. Also the same CSS class can be used by multiple tags at a time.
How to combine multiple css classes Code Example, apply same styling to multiple classes of two different elements at same time css. add multiple class name in html. add two or more classes to a element css. apply to two classes css. 2 classes for 1 element css. apply to 2 css rules. apply styling to one of two classes. add css to a div that has multiple classes.