[Doc-SIG] Cleaning up HTML output (part 1 - 'name' andnumerical ids)

fantasai fantasai@escape.com
Tue, 09 Jul 2002 10:09:49 -0400


David Goodger wrote:
> 
> fantasai wrote:
> > The above code should be written one of three ways:
> >
> > <div class="section" id="structural-elements">
> > <h1>Structural Elements</h1>
> ...
> > The first only works in browsers that support the 'id' attribute for
> > targets, but it is a cleaner syntax.
> 
> Should we be supporting older browsers?  Or can we write code to the
> latest & greatest specs exclusively?

I think it's a good idea to support older browsers--as an option, at least.
Not everybody has the latest and greatest software, and some older systems
/can't/ support the latest and greatest software.

(NS4 does not support ID targets, and it's still widely used. I'm not sure
 when IE began supporting IDs.)

> > <div class="section">
> > <h1><a name="structural-elements">Structural Elements</a></h1>
> ...
> > The third is not ideal, but it works in every HTML browser I have
> > ever come across.
> 
> It's also deprecated in the latest specs.  Will future browsers ever
> stop supporting it?

They probably won't for many years since most content on the web is
written with the <a name="fragment-id"> construct.

> > Ideally, you'd put in a <link> to the table of contents in the
> > <head>:
> >     <link rel="toc" href="#table-of-contents"
> >      title="Table of Contents">
> >
> > and leave it at that.
> 
> I don't understand how that is supposed to work.  Could you supply an
> example or a reference?

http://www.subotnik.net/html/link.html.en

> > Unfortunatly, most browsers don't support <link>.
> 
> So perhaps it's a non-issue?

Practically, yes.

> > If linking back to the corresponding toc entry is important to you,
> > then identify the entries with the section's id preceded by 'toc-'.
> > For example:
...
> 
> Since I normally don't read the raw HTML, and it's not *intended* to
> be read in raw form, I don't think the form of the IDs is that
> important.

Ah, I forgot to mention another problem with numerical IDs--
If I add or delete a chapter, all the IDs from there on change. Suppose
I had a bookmark to that part of the document. It wouldn't point to the
right element anymore. It's not critical in a table of contents, where
there's only a few list items to scroll through. But in general, you do
*not* want numerical identifiers, and it's a good practice to avoid them.

~fantasai