Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is it okay to nest H1 in Anchors?

    Code:
    <a href="/home"><h1>My Title</h1></a>
    S'ok? Or bad juujuu?

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    <h1><a href="/home">My Title</a></h1>

    semantically you should not put block elements inside inline ones

    H1 = block
    anchor = inline

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,478
    Thanks
    6
    Thanked 981 Times in 954 Posts
    No, it’s not OK as it will result in invalid HTML. As said already you can’t put block elements inside inline elements, only vice versa. Therefore, you need to put the anchor inside the h1, not the h1 inside the anchor.
    Code:
    <h1><a href="/home">My Title</a></h1>

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Sorry to bring this up again...

    Sorry to bring this up again.

    Has this rule been relaxed in HTML5? For instance, on the Apple store page, in the central content area towards the middle of the page, there are h3 tags that are nested in anchor tags. Search in the source code, for instance, for
    Code:
    <h3>iPod touch</h3>
    . When I try to validate this page, those particular tags don't come up as invalid. Any thoughts on this?

    Best Regards,
    Alex


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •