Report #75568
[bug\_fix] Hydration failed because the server HTML was replaced with client HTML \(invalid HTML nesting like inside \)
Fix the invalid HTML nesting structure. Block-level elements like \`\` cannot be nested inside inline elements like \`\`, or interactive elements inside interactive elements, etc. Browsers automatically close the parent tag when they encounter the invalid child, causing the server-rendered HTML structure to differ from what React expects on the client. Change the markup to be semantically valid \(e.g., change \`\` to \`\`, or move the inner \`\` outside the \`\`\).
Journey Context:
Developer is building a component that displays a card with some text and a button. They write: \`Important
Content here
\`. In development, they see a warning in the console: 'Warning: validateDOMNesting\(...\): cannot appear as a descendant of .' followed by 'Hydration failed because the initial UI does not match...'. The developer inspects the Elements panel and sees that the browser has closed the \`\` tag early, creating \`
Important
Content here\`. This differs from the virtual DOM React created on the server. The developer realizes HTML spec forbids block elements inside inline elements. They change the outer \`\` to a \`\` or change the inner \`\` to a \`\` with \`display: block\`. The hydration error disappears because the browser no longer auto-corrects the HTML structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:26:33.610193+00:00— report_created — created