I use this in visual studio but the compiler claimed that h1
cannot be nested in legend
element, but browser can render it anyway so i am confused
In HTML 5.2, this seems to be valid:
4.10.16. The legend element Content model: Phrasing content and headings (h1-h6 elements).
https://w3c.github.io/html/sec-forms.html#the-legend-element
This is very good news, as in complex forms, legends serve the same purpose as headings do, and e.g. screenreaders only announce legends when focusing a form element.