-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML validation error: Element "h1" not allowed as child of element "legend" #1080
Comments
@borislavpetrovhmcts This was updated in HTML5.2 so legends could include headings. See https://www.w3.org/TR/html52/sec-forms.html#the-legend-element |
Hi Boris, Steven's correct – the content model for legends was updated to allow Phrasing content and headings (h1-h6 elements) in HTML 5.2 – please see #681 for more context. |
@borislavpetrovhmcts thanks a lot for raising, let us know if you run into anything else. 😄 |
I ran into this while using https://yarnpkg.com/en/package/w3cjs module, it still throws the error, probably not updated yet. Thanks for the quick response |
@borislavpetrovhmcts I've raised an issue on their repository on your behalf, thomasdavis/w3cjs#38 |
@NickColley , the issue is not there, the w3cjs uses the standard validator url - https://validator.w3.org |
The whole thing is very strange... Also if we check earlier releases we can see the addition of the rule : So first it was implemented then removed ?!? |
I will raise it and ask the question on the validator repo |
@NickColley - what should we do now ? Ignore the validation for the radio buttons ? |
Hi Boris, Thanks for following up. Unfortunately I think we're caught in the politics of WC3 vs WHATWG here. We spent a lot of time exploring different markup options for legends or labels that are also acting as headings, testing in every browser and assistive technology we support. Of all the options we tried, this markup performed the best and we're not aware of any issues with it. I'd suggest for those reasons in this case ignoring the validator is the right thing to do. Of course, if you do come across any real-world issues in your own testing or have any other concerns, please do let us know. Thanks, Ollie |
govuk-frontend/src/components/fieldset/template.njk
Line 8 in e41a9b3
Permitted content for 'legend' element is Phrasing content. Here we have 'h1' inside 'legend',
'h1' is Flow content, which is not permitted inside 'legend'. Html validation throws and error.
The text was updated successfully, but these errors were encountered: