Forums

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

Home Forums CSS Is it okay to place multiple elements inside of an A tag?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #156574
    Alex
    Participant

    Okay, I’ve been curious about this for a while, and I avoid doing it because I always thought it was bad practice.

    Is it okay to wrap an element, for example a <div> and its contents, with an <a> tag? Is this valid? Are there any cross browser issues, including mobile?

    On MDN it states:

    Permitted content: Transparent, containing either flow content or phrasing content.

    I guess that answers my question, but it still seems odd when you have lots of elements wrapped in one <a> tag.

    Thanks.

    #156589
    Senff
    Participant

    Yep, that should be all fine.

    #156593
    noahgelman
    Participant

    Valid, yeah, technically.

    Not usually preferred, but thus is life.

    Just make sure the is set to display block so it will at least be able to handle the block elements inside it.

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