Contact Form 7
Add CSS class to wrapping DIV tag produced by Contact Form 7 (3 posts)

  1. gentlemanhog
    Posted 3 years ago #


    I'm using v3.3.1 of Contact Form 7.

    I'd like to add a CSS class to the <div> which surrounds the HTML output by the plugin, so that instead of just the default HTML, I get something like this…

    <div class="wpcf7 my-extra-css-class" id="…">

    The reason for this is so that I can quickly attach form styling rules that I am using for other forms on the site which are not generated by Contact Form 7.

    After reading through the documentation, I can't seem to find a way to do this, except to hack the plugin code - specifically the form_html() function in contact-form-7/includes/classes.php.

    Is there an option to do this?

    Many thanks.


  2. biswajeet
    Posted 3 years ago #

    Hi, you can easily add class using jquery; There is no need to alter the original code...If you can't, post form url here!

  3. gentlemanhog
    Posted 3 years ago #

    Thanks @biswajeet for the reply. Though using jQuery is an option I would rather not rely on client-side code to add the CSS class.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic