Is 'width' applicable to a textarea?

css, html, textarea, width

Solution

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.

Problem

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.

Original source