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.
Related
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.
I'm trying to create a site that has quite a few articles and wanting to have forewords in the more important ones, I've had a search and can't find anything that seems to identify what to do for this. All I can think of is using bold tags...
Is there an html tag for foreword and if not, what's the most semantic way to tag this?
EXAMPLE
<p>
<foreword>
The start of the article would go in here, typically the first sentence of the article.
</foreword>
Rest of the text for the article would go here.
</p>
No there isn't.
If you are looking to create a visually distinct lead paragraph then simply add a class that you can use to apply that styling, e.g.:
<p class="foreword">
I apply a visual intro style on my blog posts, using just a little CSS, eg:
.intro,
.post p:first-of-type {font-size: 1.3125em;}
The first paragraph in any post, or any element that I give the class .intro then adopts this visual style. Here's an example: http://internet-inspired.com/wrote/load-disqus-on-demand/
Semantically it's no different to any other paragraph though.
You should certainly not use bold tags, they do carry a semantic meaning and should not simply be used for the purpose of adding weight to your copy. To alter the visual appearance you should use only css.
Of course, html5 won't freak out of you do use a foreword tag, it wouldn't cause an error, but it just won't do anything. And it would carry less semantic value than a p tag, making it utterly pointless.
By forward do you mean introductory text? One option is to put it in a header element.
<article>
<header>
<h1>My Title</h1>
<h5>A really dull article on organic gardening</h5>
</header>
<section>
Organic gardening is.....etc. etc. etc.
</section>
</article>
According to HTML5 CR, the header element “represents introductory content for its nearest ancestor sectioning content or sectioning root element”, and a foreword can obviously be regarded as introductory. The description adds: “A header typically contains a group of introductory or navigational aids.” However, this is not meant to restrict the use to such “aids”, whatever that might mean. There is an example of a header element containing a greeting:
<header>
<p>Welcome to...</p>
<h1>Voidwars!</h1>
</header>
However, a header element is a collective element, typically containing a heading and something else. If that something else is (or contains) a foreword, there is no dedicated element for the foreword. It can be made a section element, but that’s general thematic grouping and not specifically any particular content. So you would use something like this:
<article>
<header>
<h2>Treatise on human misunderstanding</h2>
<section class=foreword>
The foreword goes here. It typically consists of a few paragraphs and a footer.
</section>
</header>
<section>The first section of the article.</section>
<section>The second section of the article.</section>
<section>And so on.</section>
</article>
However, since you say you considered using “bold tags” and show the dummy content of the “foreword” as “The start of the article would go in here, typically the first sentence of the article.”, it seems that you don’t actually mean a foreword at all. According to Merriam-Webster description, a foreword is “a section at the beginning of a book that introduces the book and is usually written by someone other than the book's author”.
I think you actually meant a headline. However, this really does not change much structurally. It could still be wrapped in a header element and even marked up as section, though that would not be very natural. A single-sentence “section” isn’t much of a section; rather, it could be a p element or just a div element, e.g. <div class=headline>...</div>.
This is all somewhat theoretical. The header element has no known impact on anything except being a block element (and its content normally causes block rendering anyway). The same applies to section. Use them if you like, but don’t expect them to “do” anything. You can use them in styling, but you could style div elements just as well.
Do you mean using forward links from one page to other? If yes, then use following anchor tag:
Name_You_Want_To_Give_To_The_Link
Eg-->
Click here
or
Click here
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."
As we know if we take h1 tag or like that, It has its own style(some bold font weight and larger size). Also there are specific built in styles for p,center,h1,h2... so on. What is difference between styling div with css(same as h1) and using h1 tag for the same Or how html work for those tags.
Apart of the obvious, default browser styles for specific HTML tags, the difference is that in HTML5 tags mark the type of data that it holds. <author>, <aside>, <address> etc.(although nothing stops you from using different type of data for those tags)
Also search engines rely heavily on the data that each html tag holds, so the data in H1 is most certainly of higher value than in a simple div which is a kind of a generic block html element that usually doesn't have any styles applied.
styling div with css(same as h1) and using h1 tag(difference)
My Answer for the above line:
H1 is the Most Important Phrase or Sentence on Your Page
If you think of a Web page as an outline, the H1, H2, etc. heading tags serve to divide the page into sections. Your most important headline is your H1 headline. This generally indicates the topic for the entire Web page and is where most people look first when they're trying to figure out what the page is about. Since search engines first priority is to provide search results that people want, they try to use the same techniques to determine what a page is about. So content in the H1 tag will be considered most important and given a slightly higher rank than other content on the page...
Source: ABOUT.com (for more information)
What is difference between styling div with css(same as h1) and using
h1 tag for the same?
HTML is not just about the 'look and feel' of a web-page, it is also about semantics.
An h1 (or the new header tag) is expressing the 'headerness' of the content, while a div (even with appropriate style) does not.
You can read more on Wikipedia: http://en.wikipedia.org/wiki/Semantic_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!