Is it bad to put tags inside tags, only for string manipulation not styling?

From the HTML 5spec:

Content model:

  • If the element has a label attribute and a value attribute: Nothing.
  • If the element has a label attribute but no value attribute: Text.
  • If the element has no label attribute and is not a child of a datalist element: Text that is not inter-element whitespace.
  • If the element has no label attribute and is a child of a datalist element: Text.

So depending on context there are two things that you can put inside an <option> — text or nothing at all — you may not put a <span> or any other element there.


From the HTML 4.01 spec:

<!ELEMENT OPTION - O (#PCDATA)         -- selectable choice -->

(Even the HTML 3.2 and HTML 2 specs say: <!ELEMENT OPTION - O (#PCDATA)*>)


An option element cannot have any child elements. So yes, it is bad.

Leave a Comment