Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In HTML5, is it better to use <section> and <h1> instead of <h2>–<h6>?

Tags:

html

In studying up on HTML5's new section tag, I'm wondering about the handling of h1, h2, h3, h4, h5, and h6 tags...

The HTML5 specification says that "[h1, h2, etc.] elements represent headings for their sections" (http://www.w3.org/TR/html5/sections.html#the-h1-h2-h3-h4-h5-and-h6-elements). Further in the spec's "4.4.11 Headings and sections" section, there are currently three examples of structuring a document about apples.

If we follow the first specification, which states that heading elements "should represent headings for their sections," it seems the third apple example is the most correct structure (i.e., using h1 tags for the heading in each section and subsection). Using this logic it seems that the h2, h3, h4, h5, and h6 tags would be used rarely, if at all.

This is what I'm wondering: should h2, h3, h4, h5, or h6 tags really be used if, in reality, they are basically marking up subsections? Does it not make more sense to use section tags to separate sections, each with their own header, rather than relying on h2, h3, etc. to start implicit sections? (The "Headers and sections" section also talks about the sections implied by using h2, h3, etc.)

Perhaps it's my relational database knowledge causing a bias, but creating multiple header tags with numbers (h 1, h 2, h 3) seems like bad practice, when technically they are each heading their own section or subsection.

What are your thoughts?

like image 347
robertwbradford Avatar asked Dec 20 '10 18:12

robertwbradford


People also ask

Is H1 better than H2?

The H in H1, H2 and H3 stands for Higher. H1 subjects are worth 1 point and H2 subjects are worth 2 points.

What is the purpose of using the tag H1 and H2 6 00?

The <h1> through <h6> tags are used to create headlines on a page, where <h1> is the most important and <h6> is the least important. These tags are used to briefly describe the content underneath them. There may be multiple of each tag on a page, if multiple sections are of equal importance.

Should a section have a H1?

An H1 should always be in the first section of the page's content (usually the logo or the level heading area). H1 tags can be used for dividing content sections (traditionally where most considered an H2). H2 tags are used as HTML head elements to detail an outline to support the H1 section label, with H3 etc.

What is the purpose of using the tag H1 H2 H3 H4 H5 h6?

The h1, h2, h3, h4, h5, h6 tags are used to create text headers for a document. They can display the header text in one of six different sizes.


1 Answers

It seems that the spec even states that h1 has preference over all the others:

Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section's nesting level.

What disturbs me however is this:

Authors are also encouraged to explicitly wrap sections in elements of sectioning content, instead of relying on the implicit sections generated by having multiple headings in one element of sectioning content.

Now it is wonderful that we got section, article, nav and aside to use to prevent div-itis. But if we need to explicitly use a section element for each section than we end up with more section elements then we ever had divs. I feel a strong case of section-itis coming on.

like image 150
Evert Avatar answered Sep 22 '22 22:09

Evert