SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should I nest H3 inside A or is it the other way?

    Hello!
    Which one is correct way to make title of the link to also be an H3 tag:

    Do I nest the A inside the H3 OR H3 inside the A:

    <h3><a href="/somwhere.htm">Some title</a></h3>

    OR

    <a href="/somewhere.htm"><h3>Some title</h3></a>

    Just wondering if these 2 are both correct or if only one is correct, then which one and why?

    Thanks
    My project: Open source Q&A
    (similar to StackOverflow)
    powered by php+MongoDB
    Source on github, collaborators welcome!

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,114
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    You must nest the <a> inside the <h3>. The rule is that inline elements (like <a> elements) cannot contain block-level elements (like <h3>s).

    (Block-level elements by default take up a line of their own and stack one atop another, while inline elements sit side by side by default.)
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    Team SitePoint AlexW's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne
    Posts
    832
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Definitely the first. <h3>s are designed to be 'block level' tags and provide fundamental structure to your document.

    <a>s are inline tags, and are designed to sit inside like that structure in the same way <strong>, <em> and <code> do.
    Alex Walker
    SitePoint Developer
    SitePoint - Learnable


Bookmarks

Posting Permissions

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