The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Anchor link containing multiple headings?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #30387

    According to the W3C wrapping multiple elements in 1 anchor tag is invalid.

    I was wondering is there is a neat CSS solution for combining multiple heading and image tags into 1 valid clickable anchor?

    I’m building a property listing site, and I want my ‘mini listing boxes’ to only have 1 anchor. Here’s my invalid code:


    Listing Title



    I think if you wrap the multiple elements in one div, you should be able to then wrap that div in an anchor tag around it and it validate


    Hmm, still seem to get a few validation errors on W3C.


    Unusual, because I just checked a page with multiple elements (An h2 and a couple p’s) wrapped in an anchor tag and it validated just fine for me. Do you have a link to the page?


    Yeah, it’s here:

    But I’m switching to spans now, as someone on Stack Overflow said I shouldn’t really use headings in this way.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.