[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
use id="xx" instead of <a name="xx"> in html output
From: |
Per Bothner |
Subject: |
use id="xx" instead of <a name="xx"> in html output |
Date: |
Mon, 8 Feb 2016 18:11:59 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
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.
These reasons don't apply as strongly to @anchor commands, so it is
plausible to keep generating <a name="Foo"> for @anchor{Foo}.
Definitions should probably use the id attribute.
However, using an id attribute doesn't answer the question: On what
element do we put the id attribute? TexInfo's nested structure
complicates this. Consider:
@node Chapter1
@chapter Chapter1
Preamble
@menu
* Section11::
* Section12::
@end menu
@node Section11
@section Section11
section11-text
@node Section12
@section Section12
section12-text
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.
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"-->
A minor nuance: Putting the node <div> on the same line
as the section <div> (with no whitespace between) means
that the node element is the firstChild of the sectioning <div>,
which slightly simplifies JavaScript navigation.
--
--Per Bothner
address@hidden http://per.bothner.com/
- use id="xx" instead of <a name="xx"> in html output,
Per Bothner <=
- Re: use id="xx" instead of <a name="xx"> in html output, Gavin Smith, 2016/02/09
- Re: use id="xx" instead of <a name="xx"> in html output, Ineiev, 2016/02/09
- Re: use id="xx" instead of <a name="xx"> in html output, Per Bothner, 2016/02/09
- Re: use id="xx" instead of <a name="xx"> in html output, Gavin Smith, 2016/02/09
- Re: use id="xx" instead of <a name="xx"> in html output, Per Bothner, 2016/02/09
- Re: use id="xx" instead of <a name="xx"> in html output, Gavin Smith, 2016/02/12
- Re: use id="xx" instead of <a name="xx"> in html output, Per Bothner, 2016/02/12
- Re: use id="xx" instead of <a name="xx"> in html output, Gavin Smith, 2016/02/14
- Re: use id="xx" instead of <a name="xx"> in html output, Gavin Smith, 2016/02/14