views:

230

answers:

7

Is it mandatory to use H2 after h1 if text is too small then can we use h4 after h1 . and is it accessible ?

+22  A: 

Technically you can use any combination of those.

Semantically, it's wise to use the common order. And if the fontsize is too small, use css to change that.

With the tags h1..h6 you give a semantical meaning to a title. Where h1 is for the toplevel, h2 for a subdivision of h1, h3 for a subdivision of h2 etc..

You can change the apearance by setting CSS rules. Which is great because now you can separate content from lay-out.

Gamecat
this is one area XHTML2 would have made things more clear. Too bad it's been canceled.
James Cassell
@James: the HTML5 standard is also pretty clear on the exact semantic meaning of those tags. I skimmed it just now, it looks terribly complex, but at least the *do* define the meaning with quite some precision. Even more: HTML5 has some conformance requirements that can't be checked by a computer (at least not until computers "understand" content).
Joachim Sauer
+1  A: 

Ideally you should stick to H1 then H2 and then use CSS to alter the styles of both to match what you want.

Think of HTML as describing the content and structure of your document (hence why it's preferred to stick to H1 then H2, because that indicates the structure of the headings), and then think of CSS as taking that structure and formatting it according to some layout rules, so the CSS defines how big and what colour your want all your H1s and H2s to be.

(Technically there is nothing stopping your from mixing up the order and doing whatever you want though)

Simon P Stevens
+8  A: 

You should always structure the document correctly, so yes it should be h2 after h1 - if the text is the wrong size, you should use CSS to style the headings to your taste.

Mark B
+1  A: 

Yes, you can skip levels, and most screen readers won't care.

It is often better to use CSS, though.

Scavenger
Screen readers don't care, but users of screen readers would most certainly care. Proper use of headings is how users of screen readers quickly navigate a page. If the order of headings is all screwed up a screen reader user will become disoriented and lost within a page's content. Most screen readers even have shortcut keys for properly navigating the headings more quickly.
+1  A: 

H1 is usally used for primary headers, h2 for subheaders, h3 for subsubheaders etc. It's doesn't really matter what order you use them in. it's just a conventional document structure, it would illogical to have a sub header, then a primary header but it's not enforced. Just style them in css for your liking.

UK-AL
A: 

No, they're just tags. The heirarchy is implied rather than defined or enforced so you can use them in any order you please.

But for readability and neatness you're better of redefining them with CSS if you don't like the sizes rather than just using H3 for a main heading and ignoring H1 and H2. Aside from anything else it could impact Search Engine Optimisation (which considers H1 significant, though I'm not sure about H2 and H3).

Jon Hopkins
H1 as least significant? Really?
Joachim Sauer
Sorry, clarified. By "H1 at least is significant", I meant H1 is significant even if H2 and H3 might not be.
Jon Hopkins
That is bad advise. Just because the browsers tolerate crap for code and the SGML form of the language is stupid understand its own structural conventions does not make bad practices acceptable. If he is a newb and trying to learn the correct way I would suggest telling him of acceptable bad practices.
@austin cheney - I do say that he <i>should</i> but strictly it's a matter of choice, the standard does not enforce it.
Jon Hopkins
A: 

h1 and h2's are pretty vital to SEO, using one h1 and mutiple h2's after is the logical thing to do.

Wolfy87
Can you explain why that was marked down? Because this is an old post?
Wolfy87