Contact Form 7 (CF7) is one of the most popular plugins available for WordPress. It allows users to quickly create customised forms, anywhere on a WordPress website.

While the forms are easy to create and implement, the fields within them are styled minimally – allowing them to blend in with most websites. The appearance of each CF7 form depends on the CSS styling applied to standard HTML form elements used in your current WordPress theme.

This article shows users, skilled at using HTML and CSS, how to style CF7 forms to their particular requirements.

Tl:dr (too long; didn’t read) version

  1. The Form Process
  2. Use Firebug or Chrome Dev Tools to examine your CF7 form
  3. CSS in your current WordPress theme
  4. Targeting CSS changes to CF7 forms
  5. Using CSS to change the appearance of the default CF7 form

You will need to be skilled at using HTML and CSS to follow along in this article. If that description does not fit you, you can learn all you need to know about both HTML and CSS at http://www.w3schools.com/ and come back to this article when you’ve done that.

You will also need to be skilled at using Firebug or Chrome Dev Tools to examine the HTML and CSS of your CF7 form in detail to follow along in this article. If that description does not fit you, you can learn about Firebug or Chrome Dev Tools and come back to this article when you’ve done that.

Table of Contents

Conditional Logic for Contact Form 7 forms

Default Contact Form 7 Form

We use the default CF7 form (normally named “Contact form 1” & installed automatically on every install of the CF7 plugin) as the basis of this article.

The actual look of this default form on your WordPress website will depend on the current WordPress theme used on your website and the CSS styling that theme applies to standard HTML form elements.

In this case our website uses the BuddyDocs theme by BuddyDev and the default Contact Form 7 form appears as follows:

Your Name (required)

Your Email (required)

Subject

Your Message

You may notice this form has a couple of styling issues:

  1. Width of the Your Message fields does not match with other fields
  2. The position of the Send button is not as we want it.

In this article we’ll be demonstrating how to change the style of this form, using HTML and CSS, to meet particular requirements.

The appearance of the default CF7 form on your WordPress website will depend on the current WordPress theme used and the CSS styling that theme applies to standard HTML form elements.

Great looking Contact Form 7 forms made easy

The Form Process

Forms are a common part of many websites and are a very powerful tool for interacting with users. They provide an easy way for visitors to your website to start a conversation with you about their particular requirements.

CF7 forms are based firmly on the more general HTML form process

While the CF7 plugin makes it quick and easy to create forms with little or no knowledge of HTML, Contact Form 7 forms are based firmly on the more general HTML form process – see http://www.w3.org/TR/html401/interact/forms.html.

HTML includes a number of elements which are specifically designed for use in forms – see http://www.w3schools.com/html/html_forms.asp. The CF7 plugin provides support for most of the commonly used HTML form elements, including some recently added new HTML5 elements.

Form appearance depends on the HTML form elements used and the CSS styling applied

The appearance of each CF7 form depends on the HTML form elements used and the CSS styling applied to these elements in your current WordPress theme.

HTML + CSS = FORM

 

HTML for CF7 Form

HTML for CF7 Form

CSS for CF7 Form

CSS for CF7 Form

In any web form, the HTML provides the form content and layout (structure) of the form while the CSS controls the forms appearance and presentation (style).

HTML – form content and layout (structure)
CSS – form appearance and presentation (style).

Quick & Easy Ready styling options for Contact Form 7 forms

HTML

The HTML in each CF7 form is created by the CF7 plugin based on information supplied by you in the Form section on the CF7 interface.

Form section of the CF7 interface

Form section of the CF7 interface

Any HTML elements added by you in the Form section on the CF7 interface are combined with HTML generated by the CF7 plugin.

HTML (supplied by you) + HTML (added by the CF7 plugin) = FORM Content & Layout (structure)

Standard HTML Form Elements

The default Contact Form 7 form uses paragraph elements (<p>Paragraph Content</p>) as the basis for the form. While this is probably the simpliest way to create a form, it has a number of shortcomings, which we discuss in further articles – ( see Why we use Fieldset, Legend & Lists in CF7 Skins and Making your form easy to read by using Fieldsets ).

You can in fact use any HTML elements you want in the Form section on the CF7 interface and this is a key part of building CF7 forms that match your functional and appearance requirements.

With practice you can learn how to create increasingly complex CF7 forms by combining your HTML elements with those added automatically by the CF7 plugin.

HTML code + CF7 Tags in CF7 Form area

The box below shows the content of the Form section of the CF7 interface for the default CF7 form.

<p>Your Name (required)<br />
    [text_ your-name]</p>
<p>Your Email (required)<br />
    [email* your-email] </p>
<p>Subject<br />
    [text_ your-subject]</p>
<p>Your Message<br />
    [textarea your-message] </p>
<p>[submit "Send"]</p>

As you examine this code you should notice that it includes:

  • Standard HTML Elements – <p>Your Name (required)<br />
  • CF7 Tags – [email* your-email]

The standard HTML Elements you add in this section are output largely unchanged by the CF7 plugin. CF7 then uses the CF7 Tags to create fully functioning standard HTML form elements which can include a number of additional HTML attributes.

If you are not sure how Contact Form 7 uses CF7 Tags you can read all about them at Contact For 7 Tag Syntax.

Completed HTML code in CF7 Form

The box below shows the complete HTML code generated on the actual website, based on information supplied by you in the Form section on the CF7 interface and the additional HTML code added by the CF7 plugin.

<div id="wpcf7-f235-p1192-o1" class="wpcf7"><form novalidate="novalidate"
  class="wpcf7-form" method="post" action="/example.com/styling-contact-form-7-forms/
  #wpcf7-f235-p1192-o1">
<div style="display: none;">
<input type="hidden" value="8" name="_wpcf7">
<input type="hidden" value="3.4.1" name="_wpcf7_version">
<input type="hidden" value="wpcf7-f235-p1192-o1" name="_wpcf7_unit_tag">
<input type="hidden" value="1cc9dc2c57" name="_wpnonce">
</div>
<p>Your Name (required)<br>
  <span class="wpcf7-form-control-wrap your-name">
  <input type="text" aria-required="true" class="wpcf7-form-control
  wpcf7-text wpcf7-validates-as-required" size="40" value="" name="your-name"></span> </p>
<p>Your Email (required)<br>
  <span class="wpcf7-form-control-wrap your-email">
  <input type="email" aria-required="true" class="wpcf7-form-control
  wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email"
  size="40" value="" name="your-email"></span> </p>
<p>Subject<br>
  <span class="wpcf7-form-control-wrap your-subject">
  <input type="text" class="wpcf7-form-control wpcf7-text"
   size="40" value="" name="your-subject"></span> </p>
<p>Your Message<br>
  <span class="wpcf7-form-control-wrap your-message">
  <textarea class="wpcf7-form-control wpcf7-textarea"
   rows="10" cols="40" name="your-message"></textarea></span> </p>
<p><input type="submit" class="wpcf7-form-control wpcf7-submit"
  value="Send"><img class="ajax-loader" src="http://buzztone.com.au/wp-content/plugins
 /contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden;"></p>
<div class="wpcf7-response-output wpcf7-display-none"></div>
</form>
</div>

Take a moment to compare these two bits of code and notice where the information from the form section of the CF7 interface has made it into the HTML on the actual website.

Tip: If you unable to understand easily what is going on in the code included in these two boxes, you probably don’t have adequate skills to change the style of CF7 forms, without at least some external support or advice.

In that case you should continue to learn what you need to know about both HTML and CSS at http://www.w3schools.com/ and come back to this article when you’ve done that.

Build multi-part forms quickly and easily within Contact Form 7

CSS classes & ids generated by CF7

You may notice that Contact Form 7 adds a number of CSS classes & ids to the individual HTML form elements – for example:

  • <div> id=”wpcf7-f8-p275-o1″ class=”wpcf7″ > … <div> – for the complete form which is given a unique id
  • <span> class=”wpcf7-form-control-wrap your-name”> … </span> – inline element which wraps each text field

These are added, by the plugin author, to allow users skilled at using HTML and CSS, to style their CF7 forms to their particular requirements.

Target CF7 classes & ids within your CF7 forms

It makes sense for you to target these individual CSS classes & ids within your CF7 forms. Use CSS inheritance to ensure that your CSS changes don’t inadvertently affect other elements on your website.

WordPress theme developers also can use these CSS classes & ids to build support for the CF7 plugin within their theme. As one of the most popular plugins in WordPress, it makes sense for theme developers to do this.

You can also give your HTML form elements individual classes & ids within the CF7 tags in the Form section of the CF7 interface. This can be very useful when you have number of elements you want to style the same way.

CF7 tag with ID & Class

CF7 tag with ID & Class

Use Firebug or Chrome Dev Tools to examine your CF7 form

At this point you should use Firebug or Chrome Dev Tools to examine the HTML and CSS of your CF7 form in detail.

Use one of these tools to explore all the HTML form elements in your CF7 form and see how each element is being styled in detail by the CSS in your current WordPress theme. In particular take note of the various style sheets that are contributing to the final style used and how individual style elements are being overwritten (or not) by the CSS hierarchy.

Once you understand how the HTML and CSS is configured in your CF7 form, you can begin to plan the CSS changes you need to change the appearance of the form to suit your requirements.

You will need to be skilled at using Firebug or Chrome Dev Tools to examine the HTML and CSS of your CF7 form in detail to follow along in this article.

If that description does not fit you, you can learn about Firebug or Chrome Dev Tools and come back to this article when you’ve done that..

CF7 Form Structure

We used Firebug to produce the following diagram which shows the overall structure if the default CF7 form we are using in this article.

The diagram shows how each element of the form is created using standard HTML form elements and how those elements are arranged in relation to each other.

With experience, using Firebug or Chrome Dev Tools should give you all the information you need to change the style of your CF7 forms quickly and easily, but it may definitely help you initially to produce a hand drawn paper sketch similar to this diagram.

Great looking Contact Form 7 forms made easy

CSS

The appearance of CF7 forms on your website will depend largely on the current WordPress theme used and the CSS styling that theme applies to standard HTML form elements.

Default CF7 CSS style

There is a common misconception that the CF7 plugin controls the appearance of CF7 forms though the plugins CSS style sheets.

In truth the Contact Form 7 plugin uses only very minimal CSS styling to allow CF7 forms to blend in with most websites. For a listing of complete style sheet used by the CF7 plugin see Default CF7 CSS style.

CSS in your current WordPress theme

The actual look of CF7 forms on your website will depend largely on the current WordPress theme used and the CSS styling that theme applies to standard HTML form elements.

To change the appearance of your CF7 forms to suit your requirements, you will need to:

  1. Understand what CSS styling is being applied to standard HTML form elements in your CF7 forms via the CSS of your current WordPress theme;
  2. Adjust the CSS used by your current theme for these HTML form elements.

For some reason many WordPress themes do not provide CSS styling for standard HTML form elements. We regard this as poor practice and always look closely at how a theme styles standard HTML form elements when selecting themes.

Importantly if your theme neglects to provide appropriate CSS for these standard HTML form elements then the appearance of your form will fall back to that provided by default by the browser – which can be different in different browsers.

Use a Child Theme to make changes to your CF7 forms CSS

The most common and preferred method to makes changes to CF7 form styling is to create a Child Theme.

Make any necessary additions to the CSS in the child themes style.css only, rather than directly in the themes styles.css. That way you don’t loose your changes when you update the theme.

The style.css file of the child theme usually imports all styling from the parent theme by including the following CSS code at the top of the child theme’s style.css file.

/* Import Parent Theme */
@import url('../twentyeleven/style.css');

Any CSS changes that alter the appearance of our CF7 forms are added below this. Due to the CSS loading heirachy, any CSS changes made here will overwrite styles previously set in the parent theme.

For a simple explanation of WordPress Child Themes see http://wplift.com/customise-wordpress-child-theme.

Alternatively you could use custom CSS plugin to make your CSS changes.

Targeting CSS changes to CF7 forms

When making CSS changes you want to make sure that your CSS changes don’t inadvertantly effect other elements on your website.

The preferred way to do this is to use CSS inheritance to target the relevant HTML elements within your CF7 forms only.

For CF7 forms we have several ids & classes which can be used to give us the necessary targeted inheritance including:

  • .wpcf7
  • .wpcf7-form
  • .wpcf7-form-control
  • .wpcf7-text
  • .wpcf7-email
  • .wpcf7-textarea
  • .wpcf7-submit

You can use Firebug or Chrome Dev Tools to explore the full range of ids & classes used by Contact Form 7.

For example we can use the class .wpcf7-form to change the appearance of all HTML input text elements within the default CF7 form only:

.wpcf7-form input {
	background: #fff;
	border: 1px solid #bbb;
	color: #4F4F4F;
}

To change the background colour of the Send button when the mouse pointer hovers over the button:

.wpcf7-form input:hover[type="submit"] {
	background:#4f2a0f;
	cursor:pointer;
	color:#fff;
}

Targeting Specific CF7 Forms

Each CF7 form has a unique id which can be targeted in your CSS changes – see Styling a Specific Contact Form 7 Form for detailed instructions on how to do this.

You can also add id and class attributes to a CF7 form by adding html_id and html_class attributes into a CF7 shortcode. This can be used to target individual forms via the html_id attribute or a number of forms using the html_class attribute.

HTML:
[ contact-form-7 id=”1511″ html_class=”cf7-psForm” title=”Personal Service Form” ]

CSS:

.wpcf7 .cf7-psForm {
    background: none repeat scroll 0 0 #fff;
    border: 1px solid #9ffffe;
    padding: 20px;
}

Quick & Easy Ready styling options for Contact Form 7 forms

Using CSS to change the appearance of the default CF7 form

Using the techniques described in this article, we can use the following CSS to change the appearance of the default CF7 form.

.wpcf7-form { 
	background:#dcc8a5; 
	padding:20px; 
	border:2px solid #f6efdf; 
	margin-bottom:30px; 
	border-radius:7px; 
}
 
.wpcf7-form input { 
	background:#f6efdf; 
	padding:5px 7px; 
	border:3px solid #ccb58c; 
	margin-bottom:8px; 
	border-radius:7px;
}
 
.wpcf7-form textarea { 
	background:#f6efdf; 
	padding:5px 0px 5px 7px; 
	border:3px solid #ccb58c; 
	border-radius:7px;
}
 
.wpcf7-form p { 
	color:#4f2a0f; 
	margin-top:10px; 
}
 
.wpcf7-form .wpcf7-submit { 
	background:#4f2a0f; 
	cursor:pointer; 
	padding-left:15px; 
	padding-right:15px; 
	color:#fff; 
	border-radius:7px;
}

Using the changed CSS given above, the default CF7 form now looks as shown below:

Your Name (required)

Your Email (required)

Subject

Your Message


You can as practice use Firebug or Chrome Dev Tools to see how we’ve styled this form.

Build multi-part forms quickly and easily within Contact Form 7

Still have questions?

If you still have questions on your Contact Form 7 Email Issues, after reading and working through the information provided in this article , you should ask your question in the CF7 support forum.

Make sure you create a separate post for your question as per the WordPress Forum Guidelines.

Please do NOT add your question to an existing question. While some may people feel adding “I’m having the same problem” is helpful in the WordPress support forums, it makes it significantly harder for forum volunteers to focus on & help solve your particular problem.

Forum volunteers answering questions in the WordPress support forums each day, really appreciate when you add your question in a separate post.

Please include a link to your Contact Form 7 form plus all your input in the Form and Mail sections of the CF7 interface. This helps others to understand your actual problem and offer a possible solution.

Alternative Support Option

I’ve recently created WP Answers – a new community for Questions & Answers on WordPress. We are using Discourse ( open-source software ) to provide a complimentary alternative to the WordPress Forums with greatly enhanced community engagement.

The WP Answers community is building a growing collection of authoritative answers to WordPress related questions every day.

WP Answers - Questions & Answers on WordPress

Would you like some direct personal help using Contact Form 7


In my time answering questions in the Contact Form 7 support forum, I’ve noticed that some users would really like to get some direct personal help from me and would be happy to pay for that advice.

I also realized that I could answer most questions on Contact Form 7 in a few minutes that some people were spending hours trying to solve – often without success.

So putting those discoveries together, I decided to offer my expertise in this area on clarity.fm to see if people find it useful.

I recommend a requested call length of 15 minutes – this is sufficient to answer most questions.

This page is still a Work in Progress

This article was created from questions asked in the CF7 support forum related to this issue. We add more information as we become aware of other issues and solutions via the CF7 support forum.

If you have something you think might help others on this issue, you can use the CF7 form below to contact us.

Please note that anything that looks like a request for support or help will be ignored.

Help others on this issue



Please note that anything that looks like a request for support or help will be ignored.

Input this code: captcha
(This helps us confirm you are real person and not a bot trying to crack our website)

(Mandatory fields marked * )

This form is made using CF7 Skins – you can use Firebug or Chrome Dev Tools to see how we’ve built it.