Report #82507
[bug\_fix] Invalid HTML nesting causing hydration mismatch \(e.g., div inside p\)
Restructure JSX to follow HTML spec—replace with or use for inline children, ensuring no block-level elements inside inline elements
Journey Context:
Developer creates a Card component with a tag for description text. Inside the paragraph, they place a styled for a highlighted badge. In development, the page renders but React shows a hydration warning. In production, the hydration fails entirely or the UI behaves erratically—clicking the card triggers events on the wrong element. Inspecting the Elements tab reveals that the browser automatically closed the tag when it encountered the , breaking React's virtual DOM reconciliation. Developer spends time checking data consistency before realizing the HTML structure itself is invalid according to HTML5 spec \(block elements inside \). Fixes by changing the outer to a or the inner to a with display: inline-block. Hydration succeeds because server and client now generate identical valid HTML trees.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:04:35.405933+00:00— report_created — created