Log in   Register a New Account

Accessify Forum - Discuss Website Accessibility

New to the forum?

Only an email address is required.

Register Here

Already registered? Log In

Proper use of heading tags

  • Reply to topic
  • Post new topic
Reply with quote Is it important for a heading tag to be immediately preceded by a opening block-level element? I have a h1 tag that's preceded by an image, and my opening div is above the image.

At http://www.w3.org/TR/html401/struct/global.html#h-7.5.5 it says:
Quote:
The following example shows how to use the DIV element to associate a heading with the document section that follows it. Doing so allows you to define a style for the section (color the background, set the font, etc.) with style sheets.
Code:

<DIV class="section" id="forest-elephants" >
<H1>Forest elephants</H1>
<P>In this section, we discuss the lesser known forest elephants.
...this section continues...
<DIV class="subsection" id="forest-habitat" >
<H2>Habitat</H2>
<P>Forest elephants do not live in trees but among them.
...this subsection continues...
</DIV>
</DIV>

If a browser strictly goes by that, then the browser might not look above my img tag for the start of the container that the heading applies to and I'd need to turn the image into a background image for the div tag, or something.
Reply with quote i'd argue that, without using DIVs or similar, the association is still implicit, so wouldn't worry too much about it...

Patrick H. Lauke / splintered
Reply with quote Well... With the knowledge that XHTML2 will introduce the section element, we could use:
Code:
<h1>Top level heading</h1>
<p>...text...</p>
<div class="section">
  <h2>Sub heading</h2>
  <p>...text...</p>
  <div class="section">
    <h3>Sub-sub heading</h3>
    <p>...text...</p>
  </div>
</div>
And that will give us some styling benefits, such as:
Code:
.section { margin: 0 5%; }
Smile

Simon Pieters
Reply with quote Even when XHTML 2 becomes popular, browsers will probably look for another way to associate a heading with its content when there's no section element, but I wonder if they would look for the nearest outer wrapper or the nearest inner wrapper.

But I think I'll "not worry too much about it" and stick with what I have.
Reply with quote
Wassercrats wrote:
Is it important for a heading tag to be immediately preceded by a opening block-level element?

Not at all. The heading is 'associated' with the following text and has very little to do with anything that comes before it.

I see nothing wrong with doing things the way you do.

Tommy has left the building
Reply with quote Can someone tell me what the supposed technical or semantic improvement is of <section> over <div>ision?
Reply with quote A <div>ision is semantically neutral. A <section> marks up a section, which is a collection of paragraphs (and other things), just like a paragraph is a collection of sentences.

Tommy has left the building
Reply with quote So a <div> is the container and a <section> the content Confused yes?

Mike Abbott
Accessible to everyone
Reply with quote A <section> will be like a specialised <div>, with a specific semantic meaning. A <h> element will be the heading for that section. Subsections will be nested <section> elements, and each one can have its own <h>. Thus we'll no longer be 'limited' to 6 heading levels, and the headings will be more explicitly coupled to a section.

The <div> element will still be useful as a semantically neutral container for things. It can contain a number of <section> elements, for instance. Smile

Tommy has left the building
Reply with quote Yea the Div Section business thru me at first to till I figured DIV is the container as it is now and section is just a "section" of the total content, so you can have more sections of a total content.

So h1-6 will be depreciated in XHTML 2.0? How far away is it from being official anyways?

--
[size=9]Kyle J. Lamson
Analyst/Programmer III, State of Alaska
Reply with quote
lsw wrote:
So h1-6 will be depreciated in XHTML 2.0? How far away is it from being official anyways?

I don't know if the old heading will be deprecated, but there's not much use for them if we get <section> and <h> elements.

I don't think XHTML 2 is anywhere near becoming an official recommendation. And once it's official, it will probably be another 15 years or so to before a majority of the browsers in use support it. (I.e. before it becomes fully usable.) We're not even there with XHTML 1 yet, for crying out loud. Sad

Tommy has left the building
Reply with quote
TOOLman wrote:
A <div>ision is semantically neutral. A <section> marks up a section, which is a collection of paragraphs (and other things), just like a paragraph is a collection of sentences.

I guess my point was - why don't they just bestow some semantic value upon division instead of introducing a 'new' element?
The notions of 'division' and 'section' are pretty much synonymous everywhere else in their use, so why not simply reflect that here?

I can't (yet) see how section will differ from division in practical terms - particularly when looking at the XHML 2.0 example posted earlier.

I don't see how they've added any real value to the scheme.
Reply with quote
Bill Posters wrote:
I guess my point was - why don't they just bestow some semantic value upon division instead of introducing a 'new' element?

Because there's still a need for a semantically neutral block-level element. Sometimes you want to group elements (e.g. to position a bunch of them together), but those elements may not be a document section.

That's like saying, 'what do we need a SPAN element for when we've got EM?' Wink

Tommy has left the building
Reply with quote
Bill Posters wrote:
why don't they just bestow some semantic value upon division instead of introducing a 'new' element?


going off topic, but i hate the idea of their proposed navigation list. it's good that they're thinking about making some more specific elements, but their solution will not work in every situation. they're being far too specific, and risk ending up with a myriad of very, extremely specific elements which, once again, won't fit all real-life content anyway.

anyway, rant over... Wink

Patrick H. Lauke / splintered
Reply with quote
TOOLman wrote:
Bill Posters wrote:
I guess my point was - why don't they just bestow some semantic value upon division instead of introducing a 'new' element?

Because there's still a need for a semantically neutral block-level element. Sometimes you want to group elements (e.g. to position a bunch of them together), but those elements may not be a document section.

That's like saying, 'what do we need a SPAN element for when we've got EM?' Wink


I thought the whole idea was to move towards slimmer, more semantically dense markup from which we simply hang the visual design.
I do kinda get it, I just think that it might be a concession to non-semantic markup habits.


Fwiw, I'm not convinced we do need <span>.
If it's worth highlighting or gathering in some way, then presumably there's semantic value in reflecting it with the use of a semantically useful tag rather than span.

I honestly don't recall the last time I used span - or saw an instance where a task was best served by a span tag rather than a semantically useful one.
(Not forgetting that semantic tags can most often be visually 'neutralised' so as retain semantic and structural meaning without necessarily having to convey visual distinction.)

Display posts from previous:   

Page 1 of 3

Goto page 1, 2, 3  Next

All times are GMT

  • Reply to topic
  • Post new topic