# Controlling or disabling cols, size etc. for text fields and text areas?

**URL:** <https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134>\
**Category:** Rails\
**Created:** [May 25, 2010, 8:32am UTC](https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134 "2010-05-25T08:32:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_KSHatch\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@William\_KSHatch\_Jr](https://www.ruby-forum.com/u/William_KSHatch_Jr)\
**Post date:** [May 25, 2010, 8:32am UTC](https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134/1 "2010-05-25T08:32:17Z")

</div>

Hi, I’m new to rails and have hit a minor snag that google isn’t helping  
with. Basically, I can’t get text fields or text areas to not include  
size and cols attributes in the tags generated when using a form\_for  
… f.text\_field … etc within my view. This results in my applied  
styles being over ridden by the attribute values and, that kinda sucks.  
Of course I can set the attributes, but that seems ridiculous. How can  
I prevent these attributes from being generated so that the css can do  
it’s rightful job? Thanks.

Bill

---

<div class="post-metadata">

**Author:** ![William\_KSHatch\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@William\_KSHatch\_Jr](https://www.ruby-forum.com/u/William_KSHatch_Jr)\
**Post date:** [May 25, 2010, 3:25pm UTC](https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134/2 "2010-05-25T15:25:34Z")

</div>

On Mon, May 24, 2010 at 5:56 PM, William K. Hatch Jr.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Basically, I can’t get text fields or text areas to not include size and cols attributes in the tags generated when using a form\_for … f.text\_field … etc within my view. This results in my applied styles being over ridden by the attribute values and, that kinda sucks. Of course I can set the attributes, but that seems ridiculous. How can I prevent these attributes from being generated so that the css can do it’s rightful job?

You can’t, and shouldn’t – they’re required; see  
[http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA](http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA)

That said, I’ve never had a problem applying CSS to tweak a textarea  
with those attributes, so perhaps you have a different issue?

## HTH,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![William\_KSHatch\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@William\_KSHatch\_Jr](https://www.ruby-forum.com/u/William_KSHatch_Jr)\
**Post date:** [May 25, 2010, 7:12pm UTC](https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134/3 "2010-05-25T19:12:10Z")

</div>

On May 25, 2010, at 9:23 AM, hassan.schroeder wrote:

> On Mon, May 24, 2010 at 5:56 PM, William K. Hatch Jr.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Basically, I can’t get text fields or text areas to not include size and cols attributes in the tags generated when using a form\_for … f.text\_field … etc within my view. This results in my applied styles being over ridden by the attribute values and, that kinda sucks. Of course I can set the attributes, but that seems ridiculous. How can I prevent these attributes from being generated so that the css can do it’s rightful job?
> 
> You can’t, and shouldn’t – they’re required; see  
> [http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA](http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA)

yes, although leaving them off doesn’t appear to cause problems. I think  
making them required is at odds with separating presentation over  
structure, however.

> That said, I’ve never had a problem applying CSS to tweak a textarea  
> with those attributes, so perhaps you have a different issue?

And you would again be correct…;-( After posting, I experimented some  
more and discovered the error; I had wrongly concluded that the  
attributes were over riding the styles. Thanks.  
Thanks.

---

<div class="post-metadata">

**Author:** ![William\_KSHatch\_Jr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f9ae1b/32.png) [@William\_KSHatch\_Jr](https://www.ruby-forum.com/u/William_KSHatch_Jr)\
**Post date:** [May 26, 2010, 11:34pm UTC](https://www.ruby-forum.com/t/controlling-or-disabling-cols-size-etc-for-text-fields-and-text-areas/189134/4 "2010-05-26T23:34:34Z")

</div>

hassan.schroeder wrote:

> On Mon, May 24, 2010 at 5:56 PM, William K. Hatch Jr.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Basically, I can’t get text fields or text areas to not include size and cols attributes in the tags generated when using a form\_for … f.text\_field … etc within my view. This results in my applied styles being over ridden by the attribute values and, that kinda sucks. Of course I can set the attributes, but that seems ridiculous. ï¿½How can I prevent these attributes from being generated so that the css can do it’s rightful job?
> 
> You can’t, and shouldn’t – they’re required; see  
> [http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA](http://www.w3.org/TR/html401/interact/forms.html#edef-TEXTAREA)

They are required in HTML 4.01. They, however, appear to be optional in  
HTML5. Still should be there for now, but hopefully some future version  
of Rails will drop them as a requirement. Waiting for Microsoft to  
create a decent browser yet again.
