let's consider the final output rendered to the user of what we want to achieve: a padded textarea with both a border and a padding, which characteristics are that being clicked they pass the focus to our textarea, and the advantage of an automatic 100% width typical of block elements.
The best approach in my opinion is to use low level solutions as far as possible, to reach the maximum browsers support. In this case the only HTML could work fine, avoiding the use of Javascript (which anyhow we all love).
The LABEL tag comes in our help because has such behaviour and is allowed to contain the input elements it must address to. Its default style is the one of inline elements, so, giving to the label a block display style we can avail ourselves of the automatic 100% width including padding and borders, while the inner textarea has no border, no padding and a 100% width.
Taking a look at the W3C specifics other advantages we may notice are:
See W3C specifics for more detailed information.
Simple example:
.container { _x000D_
width: 400px; _x000D_
border: 3px _x000D_
solid #f7c; _x000D_
}_x000D_
.textareaContainer {_x000D_
display: block;_x000D_
border: 3px solid #38c;_x000D_
padding: 10px;_x000D_
}_x000D_
textarea { _x000D_
width: 100%; _x000D_
margin: 0; _x000D_
padding: 0; _x000D_
border-width: 0; _x000D_
}
_x000D_
<body>_x000D_
<div class="container">_x000D_
I am the container_x000D_
<label class="textareaContainer">_x000D_
<textarea name="text">I am the padded textarea with a styled border...</textarea>_x000D_
</label>_x000D_
</div>_x000D_
</body>
_x000D_
The padding and border of the .textareaContainer elements are the ones we want to give to the textarea. Try editing them to style it as you want. I gave large and visible padding and borders to the .textareaContainer element to let you see their behaviour when clicked.