Official headings usage principles? [closed] - html

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
W3C doesn't explicitly say how exactly are we supposed to use headings or I can't find such information.
Resources:
http://www.w3.org/TR/html401/struct/global.html#h-7.5.5
http://www.w3.org/TR/WCAG-TECHS/H42.html
http://www.w3.org/TR/WCAG-TECHS/G141
This is very brief and raises many questions such as:
"Some people consider skipping heading levels to be bad practice. They accept H1 H2 H1 while they do not accept H1 H3 H1 since the heading level H2 is skipped." - so, should we skip them or not?
When designing a sidebar - what headings should be used? H2?
When designing a footer - what headings should be used? H2?
Headings are meant to be used for lists (like a list of posts in a footer) anyway?
Should H1 be used only once on a page?
When designing a "posts listing page" - each entry usually consists of TITLE and EXCERPT - should we use H1 for titles? Or H2 or DIV?
Since headings are block-level elements, I assume that links go inside? Same for span's that are supposed to style headings in an unusual way?
If anyone could shed some light on that, it would be great :) Thanks.

1.Some people consider skipping heading levels to be bad practice. They accept H1 H2 H1 while they do not accept H1 H3 H1 since the heading level H2 is skipped." - so, should we skip them or not?
Like Richard said, it is up to the programmer. In general, headings build structure into your page, like an outline you would make for a paper in school. There is a site, that creates an outline for you based on headings. Further WebAIM found that people using technology like knowing what level they are on, so jumping around, may confuse some.
2.When designing a sidebar - what headings should be used? H2?
I normally put a <h2> in so people can navigate to it easier/faster. To be honest, I haven't actively designed a page in a year or so, so if I was to do something, I would probably use ARIA instead if the sidebars really didn't need headings, and assign the "complementary" role. Using HTML5 I could simply use the <aside> tag, which natively has the complementary role.
3.When designing a footer - what headings should be used? H2?
I normally don't use headings in the footers. You can either assign the contentinfo role to the footer div, or use the HTML5 <footer> tag which again, has it native. This blog post on ARIA is helpful.
4.Headings are meant to be used for lists (like a list of posts in a footer) anyway?
Sure, you can do:
<h3>My favorite Movies</h3>
<ol>......</ol>
5.Should H1 be used only once on a page?
Long and unending debate. I am in the camp that H1's should be only used for the title of the content, such as only the question title here on SO. There was a discussion in the HTML5 group that new tags, such as <section> resets the heirarchy/outline that I mentioned above, and h1 can be used. I am not a fan or in favor of this.
6.When designing a "posts listing page" - each entry usually consists of TITLE and EXCERPT - should we use H1 for titles? Or H2 or DIV?
I'd use h2's
7.Since headings are block-level elements, I assume that links go inside? Same for span's that are supposed to style headings in an unusual way?
The proper way is <h_><a>Words</a></h_>.

You should read the section "Headings and sections" of the HTML5 spec. Getting the headings right is an important aspect of accessibility.
With headings (and sections) you are telling various user-agents how your page is structured, which content belongs together and which is separate from each other.
Think of a typical website with 3 columns. In the first column you have the site navigation, in the second column you have the main content and in the third column you have secondary content. Now, humans able to see might grasp immediately that there are three "areas" on the page, thanks to a different background color, margins, borders, whatever. But visually impaired or blind humans can't get clues from the graphical design of the page. Machines (like search engines) neither. Therefor we use heading/sectioning elements, so they can get the information (how the page is structured) from the markup.
Each HTML5 document has an outline, which gets created by the use of the headings h1-h6 (and hgroup) and/or the sectioning elements (section, article, nav, aside). You can think of it as some kind of TOC.
While a human able to see gets a first idea about the page structure by looking at the graphical design, humans using screenreaders and machines get this idea by reading the page outline, e.g.:
(1.) John Doe's Example Blog
(1.1) Navigation
(1.2) My first year at ACME
(1.3) Recent blog posts
This could be the outline of the following example documents:
Using headings only:
<body>
<h1>John Doe's Example Blog</h1>
<h2>Navigation</h2>
<h2>My first year at ACME</h2>
<h2>Recent blog posts</h2>
</body>
Using sectioning elements and headings with the level according to the calculated outline:
<body>
<h1>John Doe's Example Blog</h1>
<nav>
<h2>Navigation</h2>
</nav>
<article>
<h2>My first year at ACME</h2>
</article>
<aside>
<h2>Recent blog posts</h2>
</aside>
</body>
Using sectioning elements with h1 everywhere:
<body>
<h1>John Doe's Example Blog</h1>
<nav>
<h1>Navigation</h1>
</nav>
<article>
<h1>My first year at ACME</h1>
</article>
<aside>
<h1>Recent blog posts</h1>
</aside>
</body>
(The latter two are semantically equivalent!)
When using sectioning elements, you could even omit the headings altogether, the outline would still be the same, although "unnamed" (which is not very helpful!):
<body>
<nav></nav>
<article></article>
<aside></aside>
</body>
This would be the corresponding outline:
(1) (Untitled Section)
(1.1) (Untitled Section)
(1.2) (Untitled Section)
(1.3) (Untitled Section)
You can play with this online outliner to see which documents create which outlines.
so, should we skip them or not?
Why would you want to skip levels in the first place? It's probably never good, so no, you should not skip levels. But if it would happen, I wouldn't consider it a serious error.
Note however, depending on how exactly you skip, especially if you don't skip all headings of that level, a wrong outline could be created. See for example this simple document:
<body>
<h1>Interesting stories</h1> <!-- this is the site heading -->
<h2>My first snow</h2> <!-- this is a story -->
<h3>What I thought snow would be like</h3> <!-- this is a subsection of that story -->
<h3>How I experienced it actually</h3> <!-- also subsection -->
<h3>Why I'm disappointed by snow</h3> <!-- also subsection -->
<h2>More stories about snow</h2> <!-- this is not part of the story, but a kind of "See also" for the site/page -->
</body>
Now, if you'd change the last h2 to h3, suddenly this "More stories" section would become a subsection of the story. If you'd change it to h4, it would become a subsubsection.
When designing a sidebar - what headings should be used? H2?
When designing a footer - what headings should be used? H2?
These questions can't be answered in general. It depends on your site and your page and your content. But yes, in many cases for a "typical page" h2 would be the right candidate. The page heading (not to confuse with main content heading!) is h1, the main content is h2, the secondary content (sidebar etc.) is h2. If your footer would need a heading (not each one does), it would be h2 also in this case.
Headings are meant to be used for lists (like a list of posts in a footer) anyway?
It really depends on the content and the context.
The important question you have to ask (in general, for all heading decisions):
Does this content "belong" to the previous heading?
If yes:
Is it some kind of sub-section? → use a heading one level higher, resp. use a section element (and optionally a heading inside of it)
Is there no natural "sub-heading" for this content? → don't use a heading here
If no: use a heading one level lower, resp. use a sectioning element that is not a child of the sectioning element in question
(you'd have to repeat this step until your heading/section is a child of a heading that it belongs to)
Should H1 be used only once on a page?
Nope. As I explained, you could use h1 for all your headings on a page (if you use sectioning elements!).
When designing a "posts listing page" - each entry usually consists of TITLE and EXCERPT - should we use H1 for titles? Or H2 or DIV?
You should probably use an article element for each entry. So you'd get an heading automatically (= an entry in the outline), so to speak, as article is a sectioning element. Now, you could use h1 for it (no matter where the article is placed!), or you could use the calculated heading level (if the article is a direct child of body, you'd use h2. If it is one level deeper, h3. And so on.).
Use sectioning elements and headings so that a useful outline is created.
If you mark-up a webpage, look for a minute at the created outline only: Does it make sense? Do you understand by that how the page is structured, what sections it got? Is the hierarchy correct? Is a separate area/section of the page missing in this outline? Is a section a child of a section it doesn't belong to? (for example, often you see that the site navigation is a child of the page's main content, which is not correct, of course: typically they should be on the same level, both being childs of the site heading).

The <h_> tags are sort of redundant from the perspective of their original usage. With the ubiquity of CSS, a tag like <h4> is pretty much descriptive for all intents and purposes.
If you have a page with multiple sections then it makes sense to denote this somehow, and until the HTML5 <section id=""> tag is fully adopted a heading can be useful for some-thing reading the source code. Considerations might include:
Search Engine Optimisation: if you make some piece of text a heading, you are telling search engines, "hey, this is important!". To what extent this matters is for another discussion.
Code readability: if multiple people are working on the project, a heading is a good way to understand where breaks in the page copy occur. You can do this with <!-- Sidebar Here --> to a similar effect, but to some this is overkill.
"Some people consider skipping heading levels to be bad practice. They accept H1 H2 H1 while they do not accept H1 H3 H1 since the heading level H2 is skipped." - so, should we skip them or not?
This is at the discretion of the programmer. You might decide to use <h1> for page headings, <h2> for section headings, but this is not written in stone. You can restyle the headings with CSS anyway, so you can favour hierarchy over appearance. If you think your sidebar is of equal importance to your tag cloud, give them the same heading classification.
Since headings are block-level elements, I assume that links go inside? Same for span's that are supposed to style headings in an unusual way?
This is absolutely correct.
The gist of what I'm saying is that W3C standards are there for reference. The development teams that make web browsers, RSS readers, etc. care about them because it means they don't have to discuss a new tag with each other. Imagine Google, Microsoft and Apple holding cross-party talks about when a <h4> or <span> tag should be used... nightmare fuel!
If a topic like those found in questions 2-6 above aren't written in stone, common sense is the fail-safe. That, and talking to your colleagues and agreeing a way forward. Sorry to repeat myself, but standards are for reference.
Hope that helps!

Related

How to deal with multiple h1 elements on subpages

According to the HTML5.1 spec, as outlined in the link below, every page should only have one h1 element. Naturally, I feel that the h1 element on the homepage should be a title describing the website itself. This raises the question, how do you correctly deal with h1 headers on subpages if the h1 element used on the homepage is used in header?
For instance, let's assume we are building a website for Adam's Sweet Shop, we create the layout and we create our header:
<header>
<h1>Adam's Sweet Shop</h1>
...[other header elements]
</header>
Now, that works fine for the homepage. But as we delve into the subpages, we are left with two options. We create a different h1 element describing that page and delegate the header h1 into a different tag. This would seemingly satisfy the requirements of the HTML5.1 spec, but it almost seems 'hacky', plus for templates this would require two different header files.
The second option is to create two h1 elements, one describing the website in the header, the other within the main element describing the page.
<header>
<h1>Adam's Sweet Shop</h1>
...[other header elements]
</header>
<main>
<h1>About Adam's Sweet Shop</h1>
...[other body elements]
</main>
This obviously goes against the HTML5.1 spec, but seems less hacky. I originally built a site using second approach, but received a warning message from the W3C validator.
Are either of these approaches correct, and if not, what is a better approach, for instance, an ARIA label describing the 'real' h1?
https://www.w3.org/TR/html51/sections.html#the-h1-h2-h3-h4-h5-and-h6-elements
If it works better in your site design to have an h1 in the header and another h1 in the main, then that’s what you should do. Neither the canonical HTML spec nor the W3C copy of it say you shouldn’t use more than one h1 element per document if that’s what meets your needs. And the W3C HTML checker won’t report any errors or warnings for the markup example in the question.
As far as any accessibility concerns, it’s true screen readers will report both those h1 headings as being at the same (top) level, but that also seems appropriate for this particular case—it isn’t an absolute problem to have a couple top-level headings. (Though in contrast it would be a problem for screen readers if you marked up every section in your entire document with an h1—and that’s why the HTML emits warnings for that case (which is very different from your case).
HTML 5.1 has no restriction about having only one h1
The only requisits are:
The first element of heading content in an element of sectioning content represents the heading for that section. Subsequent headings of equal or higher rank start new (implied) sections, headings of lower rank start implied subsections that are part of the previous one. In both cases, the element represents the heading of the implied section.
This means that :
you must start with a h1,
you have to respect the h1>h2>h3... hiererarchy,
an heading starts a new section,
but you can perfectly start a new section at the same level as your first one
So having one h1 in both main and header sections is fine, according to the HTML specs,
it's possible, but it's (often) bad design.
You should always consider that your h1 is expected to be the webpage title (while the <title> element may already contain your website title). It makes no sense of having two titles for the webpage, for various reasons including SEO and accessibility.
So it's technically possible, HTML can be used for formatting complex multi-documents, but if you can avoid it, keep it simple.
edit
After reading through some discussions, I would no longer recommend using multiple h1 tags if you care about assistive technologies or browser outlining until the implementations are standardized.
My original answer should be valid in the future and for SEO purposes, but there is no guarantee for that.
original answer
You can have multiple h1s on a single page with the right sectioning. In HTML5, document outlines are created differently from previous versions.
Before HTML5, the whole page was considered the "root document", and the h1 was used to describe this root. It was a simple one-to-one relationship between HTML files and documents in the outline. This is important for SEO as engines use these outlines to guess what your page is about, and confusing them is a bad idea.
HTML5 introduced sectioning content such as article, section, header, footer, etc. According to the specs,
Sectioning content is content that defines the scope of headings and footers.
Each sectioning content element potentially has a heading and an outline.
This means you can use a h1 tag for every new outline created this way, because
Certain elements are said to be sectioning roots, including blockquote and td elements. These elements can have their own outlines, but the sections and headings inside these elements do not contribute to the outlines of their ancestors.
so if you use a h1 in a "child" outline created for example by nesting it in an article, it won't interfere with the outline (and thus SEO) of your parent outline.
So for all intents and purposes,
<html>
<head>
</head>
<body>
<h1>
My awesome collection of articles
</h1>
[ ... some content ... ]
<article>
<h1>
My awesome article
</h1>
</article>
</body>
</html>
is a valid use of headers and sectioning in HTML5. Also, this article does a great job at visually explaining all of this using nearly your example.

What are there guides for using Heading tags?

Instantaneous I'm working on developing a portfolio site. Hereby I strive to be as accurate as possible markup. I'm currently stuck in the use of heading tags. Are there any guidelines on the use of h1, h2, h3 tags etc? I find it difficult to determine what is and what is now an h1 h3 is an example.
I like to hear of your findings.
According to w3c:
The header element typically contains the headings for a section (an h1-h6 element or hgroup element), along with content such as introductory material or navigational aids for the section.
So the header can contain h1, etc. But not every h1 should be wrapped in a header. Only if it is related to the section.
The header tag is just semantics. It helps browsers (and developers) to understand your page better.
In fact it's always up to you how to use headers and how many of them you want to use. You should always test your site without CSS enabled and you will see if your markup is correct and articles titles / page titles/ block titles are visible enough
You can look also at some resources
http://webdesign.tutsplus.com/articles/the-truth-about-multiple-h1-tags-in-the-html5-era--webdesign-16824
http://www.hobo-web.co.uk/headers/
http://accessibility.psu.edu/headingshtml
Another great resource that explains heading tags with reference to SEO:
https://www.thiscodeworks.com/html-heading-tags-less-than-h1-greater-than-to-less-than-h6-greater-than-html-basics-htmltags-seo/5e19e63f2f9933a537bcc72d
"Best practices for SEO and accessibility purposes when using heading tags is:
Use once or twice with the title of the website of page
Use for section headers inside the page. Good to have one every 200-400 words. But totally depends on the content and layout.
- Use as many as you want to further subsection and highlight key points in the text."

Why use .h1 instead of actual h1?

Within the Bootstrap CSS project, styles are provided for your heading tags (H1, H2, H3, H4, H5, H6), but there's also a series of class names based on the headings as well (.h1, .h2, .h3, .h4, .h5, .h6). What is the benefit gained from using the class name of a H1 without properly using the H1 tag? I would think that you always want to make sure your HTML mirrors your visual importance.
Any thoughts explaining a good reason for using .h1 instead of using a h1 tag would be appreciated.
You ask:
Why use .h1 instead of actual h1?
Short answer:
The goal is to use both, together.
The usefulness of the .h* classes comes into play when the size of the typography in the design does not correlate with the semantically appropriate heading levels. By splitting the problem in two, we can cleanly solve for both.
The first bit is the element/tag. The '<h*>' takes care of semantics, accessibility and SEO.
The second bit is the class. The '.h*' takes care of visual semantics and typographical hierarchy.
Long answer:
I believe that the origins of these classes come from OOCSS project:
Object-Oriented CSS
The latest iteration of OOCSS has changed a little since I last looked at it, but here's the relevant heading.css file, from an older commit, that has the .h1 - .h6 classes that I'm familiar with:
6e481bc18f oocss / core / heading / heading.css
From the comments:
.h1-.h6 classes should be used to maintain the semantically appropriate heading levels - NOT for use on non-headings
...
if additional headings are needed they should be created via additional classes, never via location dependant styling
Note the emphasis above.
For a good explanation as to why one would use these classes, see:
stubbornella.org: Don’t Style Headings Using HTML5 Sections (Nicole, the author of this post, is the creator of OOCSS)
csswizardry.com: Pragmatic, practical font sizing in CSS
Google Groups › Object Oriented CSS › Headings question: Basic concept/usage? (A question I asked back in September of '12)
Relevant quotes from the above links:
1. stubbornella.org
... [HTML5] Section elements are meant to help the browser figure out what level the heading really is, but not necessarily to decide how to style it.
So, how do we style headings in an HTML5 world?
... We shouldn’t use sectioning elements for styling. We should let them do the job they were designed for, which is sorting out the document tree, and solve styling issues another way that meets our goals better: with simple reusable class names that can be applied to any of our headings no matter how deep they may be in the sectioning content.
I recommend abstracting site wide headings into classes because then they are portable, predictable, and dry. You can call them anything you like.
2. csswizardry.com
Another absolutely stellar nugget of wisdom [Nicole Sullivan has] given us is what I call double-stranded heading hierarchy. This is the practice of defining a class every time you define a heading in CSS.
... By assigning a class along with each heading style we now have those styles attached to a very flexible selector that can be moved anywhere, rather than to a very specific and non-movable one.
3. groups.google.com
Here's a pseudo-html5 usage example (h/t Jamund Ferguson):
<body>
<div class="main">
<h1>Main Heading</h1>
<section>
<h1 class="h2">Section Header</h1>
</section>
</div>
<aside class="side">
<article class="widget">
<h1 class="h3">Sidebar Headings</h1>
</article>
<article class="widget">
<h1 class="h3">Sidebar Headings</h1>
</article>
</aside>
</body>
Please read full articles (and thread), via links above, for more detailed information related to this question/topic.
Most stylesheets have a set of font-sizes that correspond with heading styles 1 through 6. Sometimes, elsewhere on the page, web designers want to use those same font sizes on text which should not be a part of an actual heading element, for semantic reasons. Rather than providing names for each of those sizes like .size-12, .size-14, .size-16, etc, it's easier just to name them all with class names similar to your headings. That way, you know that the text will be the same size as an H1 element, even though it's not actually an H1 element. I've done this a few times myself.
A few reasons I can think of:
Using div instead of proper tag to get the visual of a header without an impact on SEO
To avoid complications from browser inconsistencies
Compatibility with other libraries and frameworks that choose to do the same for reasons 1 and 2
Design flexibility (as noted by #scrappedcola in the comments)
This allows for a separations of visual hierarchy form semantic hierarchy. eg, I want to tell the viewer one thing, while telling a computer (search engines) something else.
<article>
<h1 class="h1">Page Title</h1>
<p>Some content</p>
<section>
<h1 class="h2">Section Heading</h1>
<div class="h6">Sub Heading</div>
<p>Some content</p>
</section>
<section>
<h1 class="h2">Section Heading 2</h1>
<div class="h6">Sub Heading 2</div>
<p>Some content 2</p>
</section>
</article>
See:
http://www.w3.org/html/wg/drafts/html/master/sections.html#headings-and-sections (toward the botton of section)
http://html5doctor.com/html5-seo-search-engine-optimisation/
http://www.youtube.com/watch?v=GIn5qJKU8VM
The only thing I can think of offhand is for search engines. Many will look at an actual h1 tag as the title or subject of a page and use that for searches, etc. Having multiple h1 tags can confuse the search engine spiders and may screw up searches that would return results for your site (I've also heard it may get you on the "bad site" list with some spiders like Google).
Having the styles allows you to have the same visual look to an element without screwing up search engines.
Another reason I have come across recently... this is not particular to Angular but it serves as a good example:
I want to create dynamic/declarative forms in Angular (see Dynamic Forms in the Angular Cookbook) and allow styled text elements. Maximum flexibility would call for allowing me to declaratively add arbitrary HTML elements to my forms, but this is open to scripting attacks, and requires explicit subversion of the Angular compiler to even allow it. Instead, I allow text elements to be added to forms, along with a class for controlling style. So I can use the .h1 style but not the h1 element.
This would definitely help in-terms of SEO and google crawlers to understand your page better.
When it reads h1, it assumes that whatever is in there must be the focal point of the page. H2, would be the second components and so on. This way Google can understand the "scope" of what your page is covering in-terms of content.
Not entirely sure, but a big variable in my opinion would be the "read" mode of pages. This would allow devices and readers to organize content especially for devices used by visually impaired people.
Also it provides structure to the page and a sense of order.

whats the correct approach to this css

I have a page where the main element is a document, in this case a privacy policy.
The privacy policy title is an <h1> with the rest of the headings following, <h2> etc.
At the side of the document, but not in the flow of the H1, I have a small submenu which also has a heading. The question is what should the heading tag be on that?
Although I'm using some html5 elements I'm not using SECTION etc, due to the reliance on javascript for older browsers.
I would say h3 according to WordPress widget-titles that are also h3
e.g.
<h3 class="widget-title srp-widget-title">
POPULAR ARTICLES
</h3>
I would stay away from h1 and h2 in widgets(sidebars). If it is h3 or h4 doesn't matter too much... imho.
because of each heading tag indicates the relative importance of each section, so it's best to start with the highest level header and work you way down. I would put it in h3
Use a H1 tag, contrary to popular belief you don't get penalized for multiple H1 tags; however it may have some effect on the SEO of your site.
For confirmation you can browse the articles below:
Is it alright to use multiple h1 tags on the same page, but style them differently?
http://www.seomoz.org/q/multiple-h1-tags-on-same-page
And most importantly, the below link offers an interesting read:
http://productforums.google.com/forum/#!topic/webmasters/kYX4Upa8_es
Snippet from the link above of particular interest:
When google is 'allocating' weight to a page, one of the factors is
the text found inside your H tags.
So if you have one H1 tag, and not much text in it, google will see
this as 'very strong text' with lots of meaning. If you have one H1
tag for a whole paragraph of text, google will see this as 'weak text'
due to the total number of words contained inside the H1 tag.
The number of H1 tags on a page also affects this, if you have two H1
tags, this 'very strong text' weight will be halved, if you have
three, it will be (well, I'm not sure if it's a third of the original
weight, or reduced by a factor of three (ie, original weight divided
by two, and then divided by two again)) and so on. So having many H1
tags is a bad idea because you will have more combined text inside H1
and it also gets divided by the number of H1 tags on the page.
As for what happens in HTML5, sorry, but I'm not sure how google views
this nested syntax, I just wanted to expand and clarify on what
Cristina was talking about.
Although if you're really paranoid about SEO just stick a H3 in there, I'm sure it doesn't matter much.
If this web page is part of a web site (and not a stand-alone document), you probably don't want to use h1 for the main content heading.
Even if you don't use the sectioning elements (section, article, aside, nav), your headings still create an outline. This outline should represent the structure of your page, similar to a ToC.
So let's think of a simple website with: a) site header, b) main content, c) site navigation
If you use h1 for the heading of your main content, the site-wide header and the site-wide navigation would be in the scope of this main content:
Privacy Policy
My cool website
Navigation
But this is not correct. "Privacy Policy" is part of "My cool website", not the other way around. And "Navigation" is not a sub-part of "Privacy Policy". So your outline should look like:
My cool website
Privacy Policy
Navigation
So the solution is: use h1 for your site-wide heading (typically the name of your company/project/person/etc.). All scopes of your page are "dominated" by this heading. This is what unites your pages to a site.
Note: if you would use sectioning elements, you could use h1 for each sectioning content.
It is considered a heading, so it should probably be <h3>.
if there are no <h3> in the main content, then use a <h3> in the sidebar.
If you want to see it as e new content, use <h1> again.
It really depends on the context you see it, or your UX'er.

H1 in article page - site title or article title?

Within an article-oriented page (such as a blog post), the <h1> element (level 1 heading) is commonly used to markup either:
the blog title (i.e. the often-large site title at the top of the page, not to the <title> element), or
the article title
What is the best choice and why?
To the site owner, who may want to shout out to the world the name of their site/blog, using a level 1 heading around the site title might seem to make sense.
From the perspective of what you are trying to communicate to the user, the site title is of less relevance - the article content is what you're trying to communicate and all other site content is secondary. Therefore using <h1> for the article title seems best.
I feel the <h1> element should focus on the article title, not the site title or other content. This does not appear to be a popular convention by any means.
Examples:
Joel Spolsky uses <h1> for the article title, and an anchor for the site title
Jeff Atwood uses no <h1> at all, <h2> for the article title and an anchor for the site title
37 Signals' SVN uses <h1> for the site title and an anchor for the article title
That's three different approaches across three sites where you might expect a strong consideration for correct semantic markup.
I think Joel has it right with Jeff a close second. I'm quite surprised at the markup choices by the 37Signals people.
To me it seems quite a simple decision: what is of greatest relevance to the consumer of the article? The article title. Therefore wrap the article title in an <h1> element. Done.
Am I wrong? Are there further considerations I'm missing? Am I right? If so, why is the '<h1> for article title' approach not more commonly used?
Is the decision of where to use the <h1> element as invariable as I put it? Or are there some subjective considerations to be made as well?
Update: Thanks for all the answers so far. I'd really appreciate some angle on how the use of the <h1> for the article title instead of site title benefits usability and accessibility (or doesn't, as the case may or may not be). Answers based on fact instead of just personal supposition will get many bonus points!
There is a W3C Quality Assurance tip about this topic:
<h1> is the HTML element for the
first-level heading of a document:
If the document is basically
stand-alone, for example Things to See
and Do in Geneva, the top-level
heading is probably the same as the
title.
If it is part of a
collection, for example a section on
Dogs in a collection of pages about
pets, then the top level heading
should assume a certain amount of
context; just write <h1>Dogs</h1>
while the title should work in any
context: Dogs - Your Guide to Pets.
As a screen reader user the heading level doesn't matter as long as it's consistent. Different blogs use different conventions, so there is no standard way to make it more accessible. Making sure the headings match to the content level is more important then what level of heading is used. For example if displaying a series of blog posts with comments all the blog posts could have heading level 2 and at the start of the comments you could have heading level 3. For an example of easy to navigate headings find any Wikipedia article with multiple sections and subsections. I can easily skip around main sections by using my screen readers navigate by heading feature to jump to any level 2 heading, and if I want to move to subsections of a given sections I will navigate to the next heading.
On your blog's home page, I would use H1 to denote the site title and H2 for the titles of the individual blog posts that are published on the front page.
When entering a particular article, though, I would use H1 for the article title and an anchor for the site title.
This is a nice and semantic setup that will also be appreciated by Google when it crawls your site.
On Wikipedia the h1-Tag contains the article-name and headings in the document start with h2. The name Wikipedia is part of the title-tag in the html-header. I also think that's the way to go. So for blogs I would do like Joel Spolsky in the examples you have given.
And I would always start with the highest level, so letting out h1 is in my opinion a bad option.
The <head> part of a HTML page has an element named <title>. As the name implies, this is for the site title.
HTML is used to structure a page into a machine parse-able form, not for layouting. If it was only about layouting, you could only use <div> and <span> blocks with different classes/ids and apply CSS to them. Instead of
<h2>Sub Header</h2>
I could use
<div class="header2>Sub Header</div>
and somewhere have some CSS code that will make this <div> look like h2 (font size, bold font, etc.). The difference is that a computer can't know that my <div> is in fact a second level header in the first example (how should it know that? I might name it differently than "header2"), however in the first case, it knows that it is a second level header by the fact that it is a <h2> element and if it wants to show the user a structured list of head-lines of a page, it can do so
Top Level Header
Sub Header
Sub Sub Header
Sub Header
Sub Header
Top Level Header
Sub Header
Sub Sub Header
Sub Sub Header
Sub Header:
by searching for the H1/H2/H3/... elements and structuring them as above. So if a computer tries to find out the title of a page, where will it look for it? In an element named <title> or in an element named <h1>? Think about that for a moment and you have your answer.
Of course you might say "But the title is not visible on the page". Well, it is usually visible in the browser window somewhere (window title or at least tab title) - however, you may want it to be visible on the page as well - I can understand that. However, what speaks about doing that? Who says you may not repeat it? But I wonder if you should use a h1 element for that.
<html>
<head>
<title>SOME TITLE</title>
</head>
:
<body>
<div id="title">SOME TITLE</div>
:
</body>
</html>
Use CSS to style #title the way you like. Make it super big and super bold and have an eye catching color if you like, nothing speaks against it. Automatic page parsers usually ignore div and span to some degree, as it tells them nothing (these are elements used to layout the page for the reader, but they say nothing about the structure of the page. LAYOUT is not STRUCTURE, you can only apply style to certain structural elements to generate a layout, but one should not be confused with the other one). Still a computer will know what the title of the page is, it knows it thanks to the title element.
For a typical website, e.g. a blog, the h1 should contain the site title. Yes, on every page of the site.
Why? In a website, there are various parts that are shared for all its webpages. Let’s take navigation as example:
<ul id="site-navigation">
<li>Home</li>
<li>About me</li>
<li>Contact</li>
</ul>
This #site-navigation is repeated on every page of the site. It represents the site navigation, not the page navigation. The difference is important! {The page navigation could be a table of contents (like in a Wikipedia article) or a pagination for a long article.}
If you’d use the article title as h1, the site navigation would be in scope of this heading.
<body>
<div>John’s blog</div> <!-- the site title -->
<h1>My first blog post</h1> <!-- the article title -->
<p>…</p>
<h2>Navigation</h2>
<ul id="site-navigation">…</ul> <!-- the site-wide navigation -->
</body>
So this markup conveys: The navigation (→ started by the h2) is part of the article (→ started by the h1). But this is not true, this navigation is not the navigation for the article. The links really are part of the whole site, and the site is represented by the site heading.
The problem becomes clearer when the article contains subheadings, too:
<body>
<div>John’s blog</div> <!-- the site title -->
<h1>My first blog post</h1> <!-- the article title -->
<p>…</p>
<h2>Why I’m blogging</h2>
<p>…</p>
<h2>Why you should read my blog</h2>
<p>…</p>
<h2>Navigation</h2>
<ul id="site-navigation">…</ul> <!-- the site-wide navigation -->
</body>
As you can see, there is no way to differentiate the article sub-headings from the navigation. It looks like the article has three sub-headings: "Why I’m blogging", "Why you should read my blog" and "Navigation".
So if we instead use h1 for the site title and h2 for the article title, the navigation can be in scope of the site heading, by using h2, too:
<body>
<h1>John’s blog</h1> <!-- the site title -->
<h2>My first blog post</h2> <!-- the article title -->
<p>…</p>
<h2>Navigation</h2>
<ul id="site-navigation">…</ul> <!-- the site-wide navigation -->
</body>
Now this markup conveys: There is a site titled "John’s blog" (→ started by the h1) and it contains an article (→ started by the first h2) and a site navigation (→ started by the second h2). Sub-headings of the article would be h3 now, of course.
Another problem by using h1 for the article title is that then there is typically content before the first heading, e.g. the site header including the site title and other stuff. For users that navigate via headings, this first content would be "invisible". So it’s good practice to give every separate block an own heading.
HTML5 formalizes this with the sectioning/outlining algorithm. It solves many outlining problems you might have had with HTML 4.01, because the content order can be (mostly) free now and you don’t have to "invent" actual headings if you don’t want to, thanks to section/article/nav/aside. But also in HTML5 the site heading should be the h1 that is a child of body but not a child of any sectioning element/root. All other sections are in scope of this site heading.
H1 in article page - site title or article title?
Both. This article is informative: The Truth About Multiple H1 Tags in the HTML5 Era.
There should only be one, and there must be one only h1; usually this is the page title.
Then it should follow h2, h3 etc.
So your page can look like this (without all the other html tags)
h1
h2
h2
h3
..etc