Is there really a legend in the title? <h1> <legend> Signature </legend> </h1>
I would like to know if I can insert a legend inside the title. Thus, a legend can also have its own hierarchy associated with the entire document.
I have more text below that is relevant, but should be highlighted for readers. In this case, personal information will be legend
and h2
at the same time. h1
will be another element on the site that I have not selected.
<fieldset>
<h2>
<legend>Personal information</legend>
</h2>
<h3>
Credentials
</h3>
<label for="username">
Username
</label>
<input id="username" type="text">
<label for="surname">
Surname
</label>
<input id="surname" type="text">
<h3>
Contact details
</h3>
<label for="street">
Street
</label>
<input id="street" type="text">
<label for="house-number">
House number
</label>
<input id="house-number" type="number">
</fieldset>
source to share
As stated at https://developer.mozilla.org/it/docs/Web/HTML/Element/legend
Allowed parent elements: A
<fieldset>
whose first child is this element<legend>
In your example, the element is <legend>
not its first child ancestor <fieldset>
, so it is not valid for HTML5 markup.
Also, note that while also returning the order of items like so
<legend><h2>Personal information</h2></legend>
the markup won't be valid as <legend>
it only allows phrasing content
source to share