Description
https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element
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.
I don't understand the rationale of WHY the content of an <option>
element is restricted to just Text
and not a PhrasingContent
. Not all human text can be represented using ONLY plain-text, we need some other inline presentational features, including for example:
<b>
,<i>
,<u>
,<s>
,<strong>
,<em>
,<var>
,<ins>
,<del>
,<code>
,<kbd>
,<em>
,<var>
,<big>
,<small>
,<sup>
,<sub>
to correctly represent notations or abbreviations (like "H2O", "1.23×1026" and not "1.23×1026", or ordinals such as "1er" and not just "1er")<abbr>
to insert accessibility features like "title" attributes for hints,<span>
if we need other style or class to make some adjustments like the line-spacing, or to select some suitable fonts, or if we want to specify colors, e.g. in a drop-down list of colors,<br>
,<nobr>
,<wbr>
if we allow an option to wrap on several lines and basically control line-wraps (without necessarily using CSSstyle=
attributes),<img>
to insert icons (e.g. in a legend-like drop-down selectors), and possibly even<video>
(or even<object>
).
We should not need to develop custom objects in Javascript. But even if we do that, we would use a "datalist" object, which would be rendered by this custom element instead of <select>
.
I absolutely don't understand the restriction even if (for now) browsers don't break and just ignore other inline elements, preserving at least their plain text content.
Note that I'm not speaking about attributes: there's sill a problem with the "opgroup" element, that still does not allow any content for itself, only a "label" attribute, which is insufficient: attributes are not suitable for human-readable text.
Shouldn't the <option>
and <optgroup>
(for inclusion in <select>
or <datagroup>
elements) be reviewed to make them more flexible?
Also look at the Unicode standard, which ALREADY admits that NOT ALL human languages can be represented using ONLY plain-text (notable examples with Egyptian Hieroglyphs or VisibleSpeech), so it REQUIRES additional rich-text markup, notably for the layout or essential presentational attributes (e.g. in notations for maths and physics, and even in wellknown languages for correct and distinctive notation of abbreviations), otherwise the plain-text alone is ambiguous or makes no sense (e.g. "1026" instead of "1026" or "CH3++OH-" instead of "CH3++OH-").
Note that for superscripts/subscripts, the pseudo-solution consisting in replacing letters or digits by Unicode superscript/superscript variants does not work for all needed characters used in human languages: these Unicode character variants are just there for compatibility with legacy encoding standards (and are poorly supported in many fonts, except a few superscripts like the ordinal 'a' and ordinal 'o' or superscript '2', which were mapped in ISO 8859-1 and so were kept in the UCS for compatiblity; as well some other Latin superscripts used in IPA notations, but missing capitals) and are not intended to cover human languages (otherwise there would be OVER ONE MILLION variants added in the UCS for all variant types, in ALL scripts all numeral systems, including symbols and punctuation, and the support of diacritics, ligatures, contextual joining, complex shaping and special clustering controls), not even English or French for all their common abbreviations: if we are forced to use the standard base alphabets to get the correct coverage (and not these limited compatiblity variants which have limited use, e.g. for IPA, with a well-defined subset of the UCS), then we create semantic ambiguities if we cannot use rich-text markup. Even for maths, Unicode and ISO decided to stop adding variants: today this is no longer needed for new development (given the advances made by today's renderers, and the fact that there's no demonstrated need to offer compatibility with older standards).