Tutorial – Styling your Contact Form 7 forms using 2 ways – 1. CSS way 2. CSS Hero Plugin

Tutorial – Styling your Contact Form 7 forms using 2 ways – 1. CSS way 2. CSS Hero Plugin

Contact Form 7 is a powerful plugin that lets you build custom HTML contact forms for your visitors. If you want to change how your forms look and feel, you can do so easily with CSS in your WordPress site. And if you have no experience with HTML or CSS (or simply don’t want to learn it), the CSS Hero plugin lets you style your forms without writing any code.

I assume that you already know how to create HTML Contact Form with this plugin. If you don’t know then please see my tutorial on Contact Form 7 plugin to create forms in your site.

In this tutorial, you’ll learn all about Contact Form 7 styling and how to apply CSS to your forms.

2 ways to style Contact Form 7 are:
  • By creating CSS for the form
  • By using CSS Hero Plugin

CSS for the Form

To add the form to a page or post, simply copy and paste the form’s Shortcode into it.

The below image illustrates a Contact Form 7 default form which contains – name, email, subject and your message fields.

CF7 default form

As you can see, the form looks very basic and has no real styling. You can style it using your WordPress theme’s CSS file, which is usually located in the theme’s folder and named style.css.

Form HTML Structure

Note that when Contact Form 7 generates a form, it creates a div with the class wpcf7 and puts all the form controls inside it. I’ll use this wpcf7 class to style

You can inspect this HTML in your Chrome browser by right-clicking the page and selecting Inspect. This shows you the HTML structure of the form.

contact form 7 HTML structure

Editing CSS

Open the style.css of your WordPress Theme in notepad or any text editor. Scroll down to it’s end and start adding the following CSS styles to it.

Style

div.wpcf7 {
    background-color: lightpink;
    border: 1px solid Orange;
    padding: 20px;
}
 
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 textarea {
    background-color: rosybrown;
    color: #FFF;
    font-family: 'Arial Rounded MT';
    font-style: italic;
}
 
.wpcf7 input[type="submit"] {
    background-color: rosybrown;
    text-transform: uppercase;
    color: #FFF;
    padding: 5px 10px;
}
Explanation
  • First I have styled the div with class wpcf7, and gave it a background color, border color and padding.
  • I then styled the text, email and text area elements placed inside this div and gave them background color, font color, font family and font style.
  • Lastly, I styled the submit button which is inside this div and gave it background color, text color, padding and made it’s text as uppercase.
To cut spam entries, you can add reCaptcha to your form, read my tutorial on Contact Form 7 reCaptcha to learn about it.

You can style the form however you like by changing the colors, fonts, padding, and more. I’ve only given a brief introduction to using CSS with forms, but once you know the basic procedure, you can do much more.

CSS for Individual Form

The CSS styles we created for the form above apply to every form on your website. So if your site has 10 forms, all 10 will have a light pink background with an orange border.

The text, email, textarea, and submit elements inside the form will get the same styling. If you want to style each form differently, update the CSS to target the div’s ID instead of its class, as I did in the previous section.

First, find the ID of the div created by the CF7 plugin by right-clicking the page and selecting Inspect.

contact form 7 div Id

In the image above, the form’s ID is wpcf7-f4-p2-o1. Keep in mind that your form will have a different ID.

Next, update the CSS we created earlier by replacing .wpcf7 with #wpcf7-f4-p2-o1. That’s it! The style now applies only to the single form with the ID wpcf7-f4-p2-o1, and every other form on your site stays unchanged.

Repeat this process with each form’s unique ID to give every Contact Form 7 form on your website its own custom style.

Updated Style is given below
div #wpcf7-f4-p2-o1{
    background-color: lightpink;
    border: 1px solid Orange;
    padding: 20px;
}
 
#wpcf7-f4-p2-o1 input[type="text"],
#wpcf7-f4-p2-o1 input[type="email"],
#wpcf7-f4-p2-o1 textarea {
    background-color: rosybrown;
    color: #FFF;
    font-family: 'Arial Rounded MT';
    font-style: italic;
}
 
#wpcf7-f4-p2-o1 input[type="submit"] {
    background-color: rosybrown;
    text-transform: uppercase;
    color: #FFF;
    padding: 5px 10px;
}

CSS Hero for Styling Forms

If you don’t know CSS and HTML, the CSS Hero plugin can help. It lets you style not just your forms but any part of your WordPress website, with no coding required.

CSS Hero is built especially for beginners. Its graphical interface lets you style Contact Form 7 forms, pages, posts, and more without writing a single line of code.

Working with CSS Hero

I will now show how to style a basic Contact Form 7 form from the beginning. For this remove the previous CSS code, which I made in the above paragraph, from the style.css file of your WordPress theme.

Then follow these steps given below:

  • 1. Install and activate CSS Hero then open the Contact Form 7 page in your browser.
  • 2. Click on CSS Hero icon on the right edge of the page.

    CSS hero toolbar

  • 3. The CSS Hero toolbar appears on the right, click the Top Blue Icon to start selecting elements.

    CSS hero top blue icon

  • 4. You can now select the different areas of the form like text control, email control, submit button, form div, etc. Here I have selected the form’s div and had set its background color to light pink.

    CSS hero styling the div background color

  • 5. In the same way you can select the different form’s elements and style them in the way you want. Finally Click the Save button to save your changes.

After styling the full form, it looks like –

contact form 7 style by CSS hero

Further Reading

I hope you found this tutorial helpful. You can now style Contact Form 7 forms easily, using either custom CSS or the CSS Hero plugin. If you have questions or feedback, please share them in the comments below.

SHARE THIS ARTICLE

  • linkedin
  • reddit
yogihosting

ABOUT THE AUTHOR

I hope you enjoyed reading this tutorial. If it helped you then consider buying a cup of coffee for me. This will help me in writing more such good tutorials for the readers. Thank you. Buy Me A Coffee