Report #12886
[bug\_fix] Hydration failed because the initial UI does not match what was rendered on the server. validateDOMNesting: cannot appear as a descendant of
Restructure the JSX to use valid HTML5 nesting rules. For example, change a wrapper to a if it contains block-level elements, or use for inline content. The root cause is that browsers auto-correct invalid HTML \(like closing a early when seeing a \), causing a mismatch between the server-sent HTML and React's expected virtual DOM tree during hydration.
Journey Context:
You refactor a blog post component, wrapping CMS content in a tag for styling. Immediately, you see a hydration error in the console. The error mentions validateDOMNesting and says cannot be inside . You inspect the Elements panel and see that the server sent Content
, but the browser parsed it as
Content
due to HTML5 parsing rules. React then sees the client-side render expects a different tree structure than what the browser created from the server HTML. You change the to a or use a with display: block, fixing the nesting violation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:15:03.802742+00:00— report_created — created