I just want to say… praise be and hallelujah!
Ralph – on the money… it’s actually kind-of a laugh – why would a footer be a heading?
RyanReese – you’re my new best friend for basically quoting what I’ve been saying for years – just because it’s text, doesn’t mean slap a P around it (or worse, things that AREN’T text that get P slapped around them! – like OBJECT or IMG – whiskey tango foxtrot territory)
@tehYoyo, (and anyone else looking to learn) one of the things about semantics that’s VERY poorly drilled in is the proper use of heading tags or even what a heading tag is FOR.
Heading tags indicate the start of a section of the page, lower order (higher numbered) headings indicating a subsection of the higher order (lower numbered) heading preceding it – which is why skipping heading levels (like say jumping from H2 to H5) is ‘broken’, and why there generally should only be one H1 on the page.
Think of it like a filesystem tree:
H1 is like root (/) – on a filesystem all files and directories are ‘under’ it… on a document the h1 is the defining instance of all content on the page; which is why as Ralph said it pretty much should be the first thing in the markup for a content element.
H2’s would be the subdirectory of root (/images, /downloads, /theme) – or each of the major subsections of the page.
H3’s of course would then be subdirectories in the top level subdirectories (/downloads/pdf, /downloads/video, /theme/scripts, /theme/images)
… and so on and so forth down the page.
When you are adding a heading there are questions you need to ask yourself:
1) Am I starting a new section?
It’s amazing how often people put headings in their code when they are NOT starting a new subsection. See this common practice of taglines:
<h1>Site Title</h1>
<h2>Tagline</h2>
Semantically and in terms of using headings properly, that’s just gibberish. Doesn’t make any sense. The tagline isnt’ starting a new subsection of the page – that borders on choosing the tag just based on it’s default appearance – and as I’ve said for ages if you choose your tag based on it’s default appearance, you’re probably choosing the wrong tags! That should either be a small tag inside the h1, or a DIV after. (maybe a P, though I’d be hard pressed to give a tagline that much weight)
2) Does this section need a heading
Footers often don’t have or warrant a heading tag – in which case you should be using HR to indicate a change in topic without a heading. That’s what horizontal rules are for. (amazing how many people think that’s “new” to HTML 5 – apparently nobody bothered reading the HTML 2 or 3 specs or bothered grasping the basic concepts of semantics)
3) is this a subsection of the header before it or kin to it.
It’s often a laugh when you see people who think they should just use heading tags ‘in order’ down the page when the various bits are not subsections of each-other… or how people will use h5’s on a sidebar for ‘lower weight’ when they are effectively saying they are subsections of the content column – making it total gibberish if you are trying to navigate by headings or pull up a document structure. This is why the practice of making the content heading a H1 is also broken gibberish; Think of a newspaper – just because “MAYOR CAUGHT TAKING MILLION DOLLAR BRIBE” is presented in a massive text as the big headline, that doesn’t mean “K-6 GETS NEW BUILDING” or “WOMAN ARRESTED FOR DOMESTIC ASSAULT” are subsections of it! (at least one would hope not)… and that’s what making a content area heading the h1 would basically be saying. You look at all the pages in a book or all the pages in a paper, what’s at the top? The name of the paper and the date - the topmost heading gluing all those pages together; just like a H1 on a website should. It might not be in the massive text it is on the cover or front-page, but that’s presentation which has absolutely NOTHING to do with semantics or structure.
Bottom line on headings, they exist to mark the start of subsections, and the end of any sibling subsection preceding it… which is why properly done semantic websites typically have this type of structure: (ooh, time to drag out some ascii art)
<h1>Site Title and/or Logo<br /><small>With tagline (if any)</small></h1>
|
+-- <h2>Content area title</h2>
| |
| +-- <h3>subsection title</h3>
| |
| +-- <h3>subsection title</h3>
|
+-- <h2>SideBar subsection title</h2>
|
+-- <h2>SideBar subsection title</h2>
|
+-- <hr /><!-- start footer content -->
Pay particular attention to that HR, indicating the footer content is NOT part of the last H2 in the sidebar! I often put a HR before the first H2’s parent wrapper as well, just for structural consistency to make sure we know anything between the h1 and h2 are unrelated. (like the menu, search form, etc)…
So incredibly simple, I’m shocked the number of people who seem to argue it or just sleaze together their pages any old way… They exist to break up your content into a meaningful structure – and it’s why all those new fancy HTML 5 structural tags are just pointless bloat.