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
Related
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm building a website that contains news. I've got a page with a list of the news articles. And a second page which shows the details of the articles.
And I've got some questions about the structure of the page which shows a single article.
Here is how the page looks like:
<body>
<header data-role="header">
<h1>Article detail</h1>
</header>
<div data-role="content">
<article>
<header>
<h2>Article title</h2>
<p class="lead">Lead</p>
<p><time datetime="2012-10-15" pubdate="pubdate">October 15, 2012</time></p>
</header>
<p>Article content</p>
</article>
</div>
</body>
In a SEO point of view, is ok if the <h1> is always the same and only the <h2> change depending of the article?
I was thinking to put the article title in the <h1> too. But it means we will have the same <h1> and <h2>. I don't really know if it's a good practice.
What's your advice?
I think having "Article detail" as heading doesn't make sense here. It would be similar if the top heading of this very question on Stack Overflow would be "Question". Or if a blog post would have the heading "Blog post".
Your example (let's assume the article title is "John Doe wins!") would produce this outline:
- Article detail
-- John Doe wins!
The page does not contain an "Article detail", it is the article itself, right?
As your pages are part of a website, the heading for the whole page should probably be the site heading (the same for all pages that belong to this site).
The article title would be the main content of that page, but it's still a "child" of the site, so it gets hierarchy level 2.
If you'd have a site navigation ("All news", "Contact", …), this would get level 2 also.
So (let's assume the site is called "ACME News") this would be a suitable outline for the page:
- ACME News
-- John Doe wins!
-- (Navigation)
As long as you use sectioning elements (section, article, nav, aside), you may use h1 everywhere. Or, as you did it in your example, use the headings h2-h6 according to the ("calculated") outline. Semantically there would be no difference.
If and how search engines handle this … well, some probably understand HTML5, some don't. Some talk about it, some not. The (good) search engines will be able to interpret the structure of HTML5 documents (resp. don't "de-rank" pages just because they use HTML5 according to the spec). It's the way how pages will be marked up, some even now and many more in the future.
For your site, I bet most search engines wouldn't even bother which way you choose. It's a relatively minor detail for this extent (only 2-3 headings per page).
Normally in SEO h1 tag is used to signify Article heading.
In blog h1 is used to highlight starting point of an article which is naturally heading of the page.
Now if you wish to keep your heading constant it wont make much difference.
What will happen if you do this is
You will be having a lot of articles under the same Heading which in turn might provide you a single backlink as it might rank your page as per the most visited article.
So with respect to aesthetic view and also for better indexing we should use different H1 tags for different articles.
I think putting article title in h2 tag will improve your SEO score. H1 tag is more important but you have to also define other SEO tags like h1 to h6, bold, italic, em tag, acronym tag, dfn tag, abbr tag and strong tag in article content for better SEO result.
Now, you can also define article tag in your content to represent your article content. It separates your article content independently from the other content on your site.
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!
Usually when I code HTML5 documents I use the following syntax:
<header class="site-header">
<hgroup class="site-brand">
<h1 class="brand-name">
Brand Name
</h1>
<h2 class="brans-slogan">
Awesome Slogan
</h2>
</hgroup>
</header>
<article>
<header class="article-header">
<h1 class="article-title">Article Header</h1>
</header>
[... content ...]
</article>
It seemed to be header the right tag for site header, but after reading the spec and outlining this code, I saw two drawbacks
header tag make its content first level, and article title 2nd
Site headers might not contain headings at all, since its purpose is to tell the user who the page belongs to.
What would be the best approach?
Your first problem is that you have two h1 tags. This is NOT proper semantic mark-up. You are correct about the header tag and it would be preferable to put you high level h tags in that area.
That being said, your original question is a design and content architecture problem. If you are going to use an h1 in your article body then you should choose a different tag to use in the header of you page.
The spec says,"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."
It does not have to, though. The h1 tag (and title tag) are your main semantic indicies for a page. You do NOT want 2 h1 tags or header tags, but these two tags do not have to go together ... but its nice if you can architecture it that way.
Your usage of header in this example is okay.
However, it's not really needed here. If you only include h1-h6 and hgroup, you don't need to specify that it's a header, because it is already clear by definition. header is useful if you want to include additional content for which it's not necessarily clear that it should belong to the header vs. the main content.
But there is no harm in using header for headings only, so go on with it if you like it, need it for CSS/JS hooks, might include additional header content in the future, etc.
header tag make its content first level, and article title 2nd
I don't understand what you mean by that. The header element doesn't influence the document outline. It's a way to differentiate between introductory content and main content.
Site headers might not contain headings at all, since its purpose is to tell the user who the page belongs to.
The header element doesn't have to contain a heading. E.g. this example would be fine:
<article>
<header>I visited Berlin last week and in this post I document what I liked about it.</header>
<p>…</p>
</article>
The footer element is similar, and for some content both elements could be suitable.
If you'd want to attribute the article author, it would go into a footer.
I use WordPress to publish news. What tags should I use for the title? h1 or h2? What tag should I use within the main page, and what tag should I use on the news' page?
<h1> tags should be used to mark up the page's most important headline.
Is the title of the news article the most important? Depends.
If the page is about the news article, its headline is probably the most important.
If you're on a page listing news articles, it's probably not the most important.
In that case, on the main page, where you list these articles, you should probably use a <h2>, or <h3>. On the single article page, it should be the top header.
And no, I don't think the site's logo/slogan should have the <h1> tag on every page. Maybe on the home page only. It's definitely not the most important headline on every page. I mean, when you come and read an article, you read the dang article, not look at the site's logo.
Madara's advice is good. Use h1 for your headlines on individual posts. Use two or three h2 tags in the body of the text for important sections.
But don't forget the importance of the URL, you need keywords in there as well.
On a news page that lists all news items, make your h1 something like, "Keyword News."
Thus, a site about Libertarian politics, that would mean your h1 on the news list page is "Libertarian News from sitename.tld" or something like that.
Sorry for a little offtopic, but you may be interested in that article:
Consistent formatting of headings (at blog.editage.com)
Its about paper publications, but knowledge about typography is very important in professional webdesign.
About header levels i have nothing to add, Madara Uchiha wrote everything.
I just finished the Code School's Functional HTML5 & CSS3 and I noticed several times they emphasized that the <header> element should contain <h1> heading (not <h2>, <h3> etc.) but they did not explain why.
Why is that? What makes the <h1> so special that it is the one that we should include in <header>?
the header of the page is like the header of a document, you'll usually find the main title of the document there. The main title of a webpage is usually put into an h1, but headers can contain lots of other things like a logo, publication date and other metadata. On many websites, the sit's header also contains its navigation.
h1 is the primary (ie: the most important) header.
The header tag is not limited to only containing the h1, but as it is the most important header on the page, that may often be the case.