SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Are these headings semantical?

    Are these headings semantical?

    <div>

    <h1>

    <p>Some text comes here that does not belong to a h2...</p>

    <div>
    <h2>...</h2>
    <p>...</p>
    <p>...</p>
    </div>

    <div>
    <h2>...</h2>
    <p>...</p>
    <p>...</p>
    </div>

    <p>Some text comes here that does not belong to a h2...</p>

    </div>


    I mean not starting with the <h2>s and ending with the <h2>s. Is this bad practice? If yes, I think I'm gonna turn down headings altogether... too restrictive...

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    that looks okay except the h1 is empty and has no closing tag
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it's not bad practice. Continue to use heading elements. If you don't use heading elements then there won't be any semantics at all -- Google and assistive technologies want to know what is a heading.

    However, this is a hole in HTML4. The last paragraph is part of the last H2 heading.

    Web Applications 1.0 (working draft) has a proposed fix by introducing explicit sectioning elements:
    HTML Code:
    <body>
    <h1>...</h1>
    
    <p>Some text comes here that does not belong to a h2...</p>
    
    <section>
    <h2>...</h2>
    <p>...</p>
    <p>...</p>
    </section>
    
    <section>
    <h2>...</h2>
    <p>...</p>
    <p>...</p>
    </section>
    
    <p>Some text comes here that does not belong to a h2...</p>
    </body>
    Here the last paragraph belongs to the H1.
    Simon Pieters

  4. #4
    Brevity is greatly overrated brandaggio's Avatar
    Join Date
    Dec 2005
    Posts
    1,424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doesn't look like there are any practical differences between a div and a section. Consensus is so damn hard to achieve but it would save some going round in circles.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    division? section? now that's semantics
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DIV is semantically neutral. It's not a section.
    Simon Pieters

  7. #7
    Brevity is greatly overrated brandaggio's Avatar
    Join Date
    Dec 2005
    Posts
    1,424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The purpose of using divisions is to create discrete sections (or whatever you want to call it) so I think this is a very poor choice of word.

    There are appear to me to be datatypes that people consistently present, hence microformats. This to me is the right approach as it is an attempt at being genuinely more descriptive instead of just pretending to be.

    "Section" may be marginally more semantic than a "generic div" but I doubt most would see them as much different if at all. This should matter - these decisions are not made by some enlightened despot or semantics czar who inherently knows better than all the rest of us.

    Our distaste for divs doesn't mean we should replace/augment them with an almost equally worthless tag.

  8. #8
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The difference is that <section> affects the document outline and <div> does not. The outline of the original markup in this thread would be:
    • Heading: ""
      Paragraph: "Some text comes here that does not belong to a h2..."
      • Heading: "..."
        Paragraph: "..."
        Paragraph: "..."
      • Heading: "..."
        Paragraph: "..."
        Paragraph: "..."
        Paragraph: "Some text comes here that does not belong to a h2..."
    ...whereas my markup snippet with <section>s would be:
    • Heading: "..."
      Paragraph: "Some text comes here that does not belong to a h2..."
      • Heading: "..."
        Paragraph: "..."
        Paragraph: "..."
      • Heading: "..."
        Paragraph: "..."
        Paragraph: "..."
      Paragraph: "Some text comes here that does not belong to a h2..."
    (That is, the last paragraph belongs to the top-level section.)
    Simon Pieters


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
  •