Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is 'width' applicable to a textarea?

Tags:

Is the CSS 'width' property applicable to a <textarea>?

In practice, people say that they use it successfully, for example using a rule like this:

textarea
{
    width:100%;
}

What's confusing me is that the CSS 2.1 specification for width says,

This property specifies the content width of boxes generated by block-level and replaced elements. This property does not apply to non-replaced inline-level elements.

I thought that a textarea is an inline-level element, because e.g. markup like this ...

<p>
This is some more text:
<textarea name="mytextarea" rows="3" cols="15">Text in the text area</textarea>
And even more, more text.
</p>

... creates a single paragraph block with text to the left and right of the <textarea>, and that therefore according to the spec the width shouldn't be applicable.

like image 449
ChrisW Avatar asked Aug 31 '09 19:08

ChrisW


1 Answers

Textarea is an inline level element… a replaced inline element (you get a form control, not the simple content of the element).

The spec excludes non-replaced inline elements, but textarea is not one of them.

like image 111
Quentin Avatar answered Oct 12 '22 08:10

Quentin