Where To Put
Where to put around other html element or not? Option1- put around input element : Option2:
Solution 1:
The latter. This way you can set style, width etc. without affecting <input>
. It's also better semantically: The label is a label, and input is an input.
Solution 2:
Firstly, in the first example the <label>
is automatically linked to the <input>
, while in the second example they are not (you must set the for and id attributes to emulate the former's behaviour).
Other than that, it's a matter of situation and preference. Personally I usually go for the former as there's less markup needed.
Solution 3:
The second is definitely better, it allows you to style separately.
You can also use the "for" attribute to bind it to an input field:
Post a Comment for "Where To Put