Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Mason A. Clark
July 7, 2005, 11:07 am
rate this thread
This seems too simple by I can't find the answer.
Must <a name="foo"> be closed with </a> ?
Must it have content?
W3C says the content cannot be block so what if :
<h2>Foo Is Good</h2> ( a likely location )
Where does the closer </a> go?
<a name="foo"> </a> is ok but uses a line
<h2>Foo Is Good</h2>
On 7-7-2005 9:07, Mason A. Clark wrote:
For HTML 4.01: Yes, "Start tag: required, End tag: required", see
No, however "User agents should be able to find anchors created by empty
A elements, but some fail to do so."
<h2><a name="foo">Foo Is Good</a></h2>
Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
That's exactly what got me into this: - failure to find empty <a...></a>
<H2 id="fooname" .. has been suggested.
But the W3C site says:
"However, browser support for ID link destinations is very poor, so A NAME will
be needed for quite awhile. "
At the moment I'm stuck with <a name="foo"> </a> and a line
used for the space.
Mason A. Clark wrote:
Can't say I've found a user agent yet that fails to find <a id="foo"
name="foo"></a>. Anyone know which one would fail that?
Els http://locusmeus.com /
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Squeeze - Can of Worms
IIRC, Netscape 4. I didn't find the quoted page at W3C, but a similar
page at <http://www.htmlhelp.com/reference/html40/special/a.html is
dated from 1998, when NS4's various incompetencies would have merited a
warning like this.
Ohio Library and Information Network
On Thu, 7 Jul 2005, Mason A. Clark wrote:
Use a formal validator to verify the answers to most of your
In theory "not necessarily", but some older browsers do require it or
they don't work. Whether you can be bothered to be compatible with
such older browsers is probably your choice now - some authors feel
that using the id= attribute on the appropriate element (in your case
the "h2") is now adequate and the use of "a name=" is a superfluous
compatibility feature, we can't tell you what your decision should be
on that, but let's assume that you still want to...
right, and so will a formal validator
Put <a name="foo" id="foo">...</a> inside the block element if you
want to cover all bases. One possibility would be:
<h2><a name="foo" id="foo">Foo Is Good</a></h2>
No need to invent fake content!
Watch your CSS styles - if you've specified a style for /all/ "a"
elements, then it's going to get applied to this "a" element too,
which might not be what you want. Use a:link etc. to make the styles
hope this helps.
On Thu, 7 Jul 2005 17:26:53 +1000, Mark Parnell
But content is necessary for Opera to find it.
In Opera <a name="foo"></a> does not work.
In IE6 <a href="top"> goes to the top of the page even if there
is no <a name="top"> of any kind.
IE6 recognizes "top" . Other <a href="goo"> do NOT go to the top.
Is it just me? Or am I the only one testing?
Try this validated page on the world's best browser, Opera:
Look for the "Return to the top" link at the bottom of the page.
Look for your <a name="top" id="top"></a> below <body>
Opera needs content in <a...></a> IE6 and Firefox do not.
Mason C (now I have to go stuff content in all my 47 pages)
"Mason A. Clark" wrote:
Any <a> tag requires a closing </a>. This is because the anchor
(element using the <a> tag) may indeed have content; thus, a
closing tag is required to end the content whether or not the
anchor has any actual content.
When I use the NAME attribute, I use a blank content:
<a name="foo"> </a>
I put this just before the section of the page to which I want it
to apply. Thus:
<a name="foo"> </a>
<h2>Foo Is Good</h2>
I do it this way because selecting the link
<a href="#foo">Go To Foo</a>
with some browsers positions the window with the anchor at the very
top of the page. With the anchor before the applicable section,
the section is then positioned slightly below the top of the page.
I use the NAME attribute for the anchor instead of ID because NAME
is specifically the attribute for "the destination of another link"
(HTML 4.01 specification). The ID attribute is more general and
thus less mnemonic. Since I manually edit my HTML, mnemonic
markups are very important to me if I am to modify a page I haven't
touched in over a year.
David E. Ross
I use Mozilla as my Web browser because I want a browser that
complies with Web standards. See <URL:http://www.mozilla.org/>.