Removing p and br Tags from Contact Form 7

Table of Contents

Want to get professional advice?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Table of Contents

How to Remove p and br Tags from Contact Form 7?

Contact Form 7 (CF7) is one of the most popular free form plugins for WordPress. With CF7, it’s easy to create any form you want.

Although it’s an excellent extension, there’s always an annoying behavior. By default, it wraps our lines in <p> tags as in the case of general messages.

Unlike in this post, this is often not so useful because we often want a custom layout for our forms that is driven by paragraph component overflow.

Here’s a way to remove all <p> and <br /> additions from your forms!

CF7 is a great tool but sometimes it adds a little extra HTML that you might want to get rid of in your pages and posts.

Short Code and It’s Solved

We’ve created a quick code snippet that you can use to remove <p> and <br /> from Contact Form 7.

Luckily, it’s easy to turn off, add the following line to your wp-config.php file:

// Remove auto p and br from Contact Form 7
define( 'WPCF7_AUTOP', false );

Another option is to use a filter in your theme (functions.php) or in your plugin:

// Remove auto p and br from Contact Form 7
add_filter('wpcf7_autop_or_not', '__return_false');

The last code snippet does the same thing but attaches the code to the theme and not to your WordPress instance.

About the author

Ben Kalsky, Founder & Partner at Digitizer

Ben has 13+ years of experience building websites for technology companies, e-commerce businesses, and service providers across Israel and internationally. As co-founder of Digitizer, he’s delivered over 100 projects ranging from โ‚ช5,000 landing pages to โ‚ช100,000+ enterprise platforms.

Notable work includes:

  • Building platforms for companies later acquired by Fortune 500 firms (CrowdStrike, Nvidia)
  • Migrating 50+ businesses from proprietary platforms to WordPress, saving an average of โ‚ช80,000/year in platform fees
  • Managing infrastructure for 100+ websites with 99.9% uptime over 3 years

Ben specializes in WordPress, WooCommerce, automation, and helping businesses make smart technology decisions that scale. His approach: practical, process-based solutions that drive measurable business growth – no buzzwords, no vendor lock-in.

On Digitizer’s blog, he shares real-world insights on website pricing, platform selection, and avoiding costly mistakes when building digital infrastructure.

Connect on LinkedIn | Free Consultation | More Articles

Share the article

Copy

More articles