bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use id="xx" instead of <a name="xx"> in html output


From: Gavin Smith
Subject: Re: use id="xx" instead of <a name="xx"> in html output
Date: Tue, 9 Feb 2016 05:37:24 +0000

On 9 February 2016 at 02:11, Per Bothner <address@hidden> wrote:
> Currently, in html output the node "Foo" generates a <a name="foo">
> element.  In general I think it is better to an id="Foo" attributes.
> Reasons that come to mind:
> (1) Simpler and less cluttered html, since we can attach the id attribute
> to some other suitable element, rather than generating a separate one.
> (2) JavaScript code can use getElementById to find the node.
> (3) Better logical structure, since we can attach the id to something
> that "represents" the node - typically a <div> node.

Reason (2) is a good reason, although I wonder if there isn't some
other way to achieve the same result in JavaScript. For example,
follow a hyperlink to "#Foo" where "Foo" is the name of the node.

Reason (3) I discuss below. Reason (1) is minor.

Another problem is whether this use of "id" is valid for the version
of HTML we target: the files are declared as "HTML 4.01 Transitional",
but I read that this use of the "id" tag was only introduced in HTML5?

> I suggest two categories of <div> elements:
> A "node" includes all the content of a single node,
> but *not* sub-nodes.leaves unanswered
> A "chapter" or "section" (or "part" or whatever) <div>
> encloses the current node - and sub-nodes.

I see no need for a two levels of <div>. "Nodes" are an artifact of
the Texinfo source. They don't have an idiomatic meaning in HTML. In
the Info format, they define the target of a cross-reference and also
define a sub-unit of the Info file.

The idiomatic way to show a chapter structure in an HTML file is with
the heading commands <h1>, <h2>, <h3> etc. No need to wrap each
section in two layers of <div>s.

>
> The id attribute could logically go on either the node
> or the section/chapter element.  Putting it on the sectioning div
> seems better, since it generalizes to subsections that aren't nodes.
>
> <div class="chapter" id="Chapter1"><div class="node">
> LINKS for chapter1
> <h2>Chapter1</h2>
> Preamble
> <table class="menu">...</table>
> </div><!--end of "node"-->
>
> <div class="section" id="section11"><div class="node">
> LINKS for section11
> <h3>Section11</h3>
> section11-text
> </div><!--end of "node"-->
> </div><!--end of "section"-->
>
> <div class="section" id="section12"><div class="node">
> LINKS for section12
> <h3>Section12</h3>
> section12-text
> </div><!--end of "node"-->
> </div><!--end of "section"-->
>
> </div><!--end of "chapter"-->

Something like:

> <h2>Chapter1</h2>
> Preamble
>
> <h3>Section11</h3>
> section11-text
>
> <h3>Section12</h3>
> section12-text

is more idiomatic HTML.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]