Sunday, 14 August 2016

html - Should I put input elements inside a label element?



Is there a best practice concerning the nesting of label and input HTML elements?



classic way:








or






Answer



From w3: The label itself may be positioned before, after or around the associated control.












or












or











Note that the third technique cannot be used when a table is being used for layout, with the label in one cell and its associated form field in another cell.



Either one is valid. I like to use either the first or second example, as it gives you more style control.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...