Is it ok to put other elements like <h1> <h2> <b>
inside <label>
elements, or it is better to use style?
<label for="B"><b>like this</b></label>
<label for="h1"><h1>like this</h1></label>
it is working, but is it a good coding
Is it ok to put other elements like <h1> <h2> <b>
inside <label>
elements, or it is better to use style?
<label for="B"><b>like this</b></label>
<label for="h1"><h1>like this</h1></label>
it is working, but is it a good coding
2
Answers
Do not use headings for styling. That’s not their purpose. Use them to create a sensible document structure in a logical cascade.
Per MDN,
font-weight
styles should be used over<b>
(in general, not just in labels)As for headings, they are block level elements so should not be inside a label (which is an inline element). In general, headings should not be used to just change the font size of an element (source).