Report #35824
[bug\_fix] validateDOMNesting\(...\): cannot appear as a descendant of / Hydration failed because the initial UI does not match \(invalid HTML nesting\)
Replace semantic HTML tags with or , or restructure the component to avoid nesting block-level elements inside inline elements \(e.g., don't put inside \). Root cause: HTML specification forbids certain nestings \(block inside inline\). The browser automatically closes tags to fix invalid nesting, causing React's server HTML to differ from the client HTML React expects.
Journey Context:
Developer creates a Card component with a tag for text content, then nests another component inside that renders a . In development, sees warning about validateDOMNesting but ignores it. In production with SSR, sees hydration error. Confused because the code looks correct. Inspects browser DevTools, sees that the browser injected a closing
tag before the , breaking the React tree. Changes the to a or changes the child to use with display: block. Hydration succeeds. Developer learns about HTML content models and React's strict hydration checking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:36:12.814642+00:00— report_created — created