Title: Remove size attribute from input fields
Last modified: December 5, 2016

---

# Remove size attribute from input fields

 *  Resolved [Sprul66](https://wordpress.org/support/users/sprul66/)
 * (@sprul66)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/remove-size-attribute-from-input-fields/)
 * Is there a filter function or hook to remove the automaticly inserted “size” 
   attribute?
 * This is what I get:
    <span class=”wpcf7-form-control-wrap firstname”><input type
   =”text” name=”firstname” value=”” size=”40″ class=”wpcf7-form-control wpcf7-text
   wpcf7-validates-as-required half” aria-required=”true” aria-invalid=”false” placeholder
   =”Vorname”></span>
 * This is what i would like to get:
    <span class=”wpcf7-form-control-wrap firstname”
   ><input type=”text” name=”firstname” value=”” class=”wpcf7-form-control wpcf7-
   text wpcf7-validates-as-required half” aria-required=”true” aria-invalid=”false”
   placeholder=”Vorname”></span>
 * Another question:
    Is there a hook to add the input class to the wrapper span?
 * Thanks in advance!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Sprul66](https://wordpress.org/support/users/sprul66/)
 * (@sprul66)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/remove-size-attribute-from-input-fields/#post-8515707)
 * Here is the answer to my own question. But this doesnt helped me out with my 
   main problem (percentage width on the input or wrapper tag). Anyway, just replace
   size=”100″ with whatever you need:
 *     ```
       add_filter( 'wpcf7_form_elements', 'remove_attr_size' );
       	function remove_attr_size( $content ) {
       		$content = preg_replace('/ size=".*?"/i', ' size="100"', $content);
       		return $content;
       	}
       ```
   
    -  This reply was modified 9 years, 5 months ago by [Sprul66](https://wordpress.org/support/users/sprul66/).

Viewing 1 replies (of 1 total)

The topic ‘Remove size attribute from input fields’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Sprul66](https://wordpress.org/support/users/sprul66/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/remove-size-attribute-from-input-fields/#post-8515707)
 * Status: resolved