☆ 17 r/frontend ·by Lena ·2026-10-29 Is a button inside an anchor actually invalid HTML? 1462 views I have a card wrapped in an anchor with a button inside for saving. It works in browsers but a validator complains. What is the right pattern? ⧉ Copy link⚑ Report
☆ 0 T Tom ·2026-10-29#1 Nested interactive elements are invalid and keyboards get confused. Make the card a div, put the anchor inside, and stretch it with a ::after pseudo-element. ⧉ Copy link⚑ Report
☆ 0 L Lena ·2026-10-29#2 Then how does the save button stay clickable above the stretched link? ⧉ Copy link⚑ Report
☆ 0 C Chloe ·2026-10-29#3 Give the button position: relative and z-index: 1. The stretched link covers the card, but the button sits above it in stacking order. ⧉ Copy link⚑ Report
3 replies