[material-ui][Accordion] Default Accordion now uses div's nested within a heading tag, which is invalid HTML #44153
Labels
accessibility
a11y
breaking change
bug 🐛
Something doesn't work
component: accordion
This is the name of the generic UI component, not the React module!
regression
A bug, but worse
Steps to reproduce
Link to live example: (required)
Steps:
Current behavior
Accordions have nested
div
's within a single heading (h3
) tag, which is invalid HTML.Expected behavior
Accordion should generate valid HTML.
Context
Hi there. In the process of upgrading my MUI version to
v6.1.4
I came across notes on changes to the Accordion component. When I saw that it mentioned the "Accordion Summary is now wrapped with a default<h3>
heading element" I found that strange, as I remembered the nested Accordion content was rendered within divs.In inspecting the
v6.1.4
Accordion HTML from the live docs, and inspecting my newly upgraded local code, I found that the Accordion content divs were in fact now being rendered with an h3 element.Heading elements cannot contain
div
elements, as that is invalid HTML. Heading elements can only contain what are referred to as "phrasing elements" which are things likespan
,strong
,em
,button
, etc. Stackoverflow post, whatwg/html thread.I traced back this back to this issue and this PR. In the example brought up in that thread, within the
h3
, onlybutton
's andspan
s are rendered, which is valid HTML. There are no nesteddiv
's.If you look at the live Accordion docs page, you can see the nested divs.
To test what I'm saying about the invalid HTML, you can use the official W3C markup tester: https://validator.w3.org/nu/#textarea.
Provide this to pass as valid HTML.
Provide this to fail as invalid HTML.
Anyways, I just wanted to raise.
To get around this locally for now, I'm using the following to set the
h3
back to adiv
:Your environment
npx @mui/envinfo
Search keywords: Accordion
The text was updated successfully, but these errors were encountered: