skip to Main Content

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


  1. Do not use headings for styling. That’s not their purpose. Use them to create a sensible document structure in a logical cascade.

    Login or Signup to reply.
  2. Per MDN, font-weight styles should be used over <b> (in general, not just in labels)

    However, you should not use <b> for styling text or granting importance. If you wish to create boldface text, you should use the CSS font-weight property. If you wish to indicate an element is of special importance, you should use the <strong> element.

    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).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search