473,406 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Empty a valid or not?

According to the specs
(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element
requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to
4.01, it won't validate, it'll want to find the </A> tag.

However, when I write a document containing, say, <a name="foo" /> it
validates in XHTML 1.0.

I'm obviously missing something here, as this confuses me somewhat. Does
the magical / make the empty a element valid? And doesn't this violate
http://www.w3.org/TR/xhtml1/#C_3 ?

Nearest I can figure, it's recommending that although the tag will
validate, we still shouldn't do it in case a UA can't handle an empty a
element. Am I on the right track?

If not, feel free to correct me.
Jul 20 '05 #1
18 2434
Neal <ne*****@spamrcn.com> wrote:
According to the specs
(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element
requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to
4.01, it won't validate, it'll want to find the </A> tag.

However, when I write a document containing, say, <a name="foo" /> it
validates in XHTML 1.0.

I'm obviously missing something here, as this confuses me somewhat. Does
the magical / make the empty a element valid? And doesn't this violate
http://www.w3.org/TR/xhtml1/#C_3 ?

Nearest I can figure, it's recommending that although the tag will
validate, we still shouldn't do it in case a UA can't handle an empty a
element. Am I on the right track?


Consider dropping the silly construct completely:

<h3 id="s5">Section 5</h3>

--
Spartanicus
Jul 20 '05 #2
Neal:
According to the specs
(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element
requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to
4.01, it won't validate, it'll want to find the </A> tag. However, when I write a document containing, say, <a name="foo" /> it
validates in XHTML 1.0.


In HTML 2.0 to 4.01 you must write "<a ...>...</a>".

In XHTML you can also write "<a ... />".

The rules are different. In XHTML such an added "/" at the end of a
start tag closes the element. That is unknown in older HTML.

Writing "<a ... />" might however not work well in old user agents that
don't know anything about XHTML.

Do look up the specification for XHTML 1.0.

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #3
Spartanicus <me@privacy.net> wrote:
Consider dropping the silly construct completely:

<h3 id="s5">Section 5</h3>


It's not silly if you need or wish to have your document working on
Netscape 4 too. The poor browser does not jump to anchors defined by id
attributes, it needs <a name>. Personally I'm moving to id attributes
in new documents, mostly, but with some hesitation.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #4
Jukka K. Korpela:
Spartanicus <me@privacy.net> wrote:
Consider dropping the silly construct completely: <h3 id="s5">Section 5</h3>

It's not silly if you need or wish to have your document working on
Netscape 4 too. The poor browser does not jump to anchors defined by id
attributes, it needs <a name>. Personally I'm moving to id attributes
in new documents, mostly, but with some hesitation.


I hesitated too, but finally I moved to "id"s on all of my pages.
I haven't had one single complaint.

I guess it all depends on how important your anchors are, and on how
many of your visitors use Netscape 4.

(Netscape 4 users are probably quite accustomed to things not working
very well by now... Maybe they like pain...)

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #5
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote:
Consider dropping the silly construct completely:

<h3 id="s5">Section 5</h3>
It's not silly if you need or wish to have your document working on
Netscape 4 too.


That doesn't make the *construct* less silly.
The poor browser does not jump to anchors defined by id
attributes, it needs <a name>.


I know, and don't care.

--
Spartanicus
Jul 20 '05 #6
CJM
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:Xn*****************************@193.229.0.31. ..

It's not silly if you need or wish to have your document working on
Netscape 4 too. The poor browser does not jump to anchors defined by id
attributes, it needs <a name>. Personally I'm moving to id attributes
in new documents, mostly, but with some hesitation.


I tend to use both name & ID; it seems a bit inefficient but different
things need each of them.

In addition to NS4, I need the NAME attribute for ASP forms...

But my Javascript validation code needs the ID...

Chris
Jul 20 '05 #7

"Neal" <ne*****@spamrcn.com> wrote in message
news:op**************@news.rcn.com...
According to the specs
(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element
requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to
4.01, it won't validate, it'll want to find the </A> tag.

However, when I write a document containing, say, <a name="foo" /> it
validates in XHTML 1.0.

I'm obviously missing something here, as this confuses me somewhat. Does
the magical / make the empty a element valid? HTML is HTML and XHTML is XHTML. Each has its own rules, and even though
they have much in common, you can't determine the correctness of an
expression in XHTML document by the rules of HTML.

Also, don't confuse an empty element with the omission of the closing tag.
In HTML,

<p>Paragraph 1<p>Paragraph 2</p>

has two P elements, neither of which is empty, but the closing tag for the
first is missing. On the other hand, while you have to have a closing tag
for an A element, as you noted, an empty A is perfectly valid:

<a name="foo"></a>

Finally, in XHTML, <tag /> means <tag></tag>. In the case of <a name="foo"
/>, the slash isn't making anything valid. In XHTML as in HTML, an empty A
element is valid, whether written as <a name="foo" /> or as <a
name="foo"></a>.
And doesn't this violate http://www.w3.org/TR/xhtml1/#C_3 ?

Nearest I can figure, it's recommending that although the tag will
validate, we still shouldn't do it in case a UA can't handle an empty a
element. Am I on the right track?


It's not directly about whether a non-XHTML UA can handle an empty element,
but about how it will treat the lack of an explicit closing tag.

1. It's fine to use <tag /> for elements that, in HTML, have no closing tag,
either required or optional. (These are *by definition* empty, but the
emptiness is not directly the issue here.)

For example, if an HTML-only UA reads <input ... />, it will treat it as
<input ...>, which doesn't *have* a closing tag in HTML, so the UA won't
think anything is unusual, and will process the tag correctly.

2. The <tag /> form won't validate for elements that, in HTML, have a
mandatory closing tag.

For example, if an HTML-only UA reads <a name="foo" />, it will treat it as
<a name="foo"> but it won't find a closing tag, which will be an error that
the UA will handle however it normally handles that situation.

3. The result of <tag /> may not be the one intended, in the case of
elements that, in HTML, have an optional closing tag.

For example, if an HTML-only UA reads <p />, it will treat it as <p>, and
will then follow the usual rules for assuming an implicit </p> just before
the start of the next element that can't be nested inside a P element. So

<p />Foo<p>Bar</p>

will be treated as

<p>Foo</p><p>Bar</p>

and not as

<p></p>Foo<p>Bar</p>

Jul 20 '05 #8
In article <bu************@ID-209813.news.uni-berlin.de>,
cj*****@yahoo.co.uk enlightened us with...

I tend to use both name & ID; it seems a bit inefficient but different
things need each of them.

In addition to NS4, I need the NAME attribute for ASP forms...

But my Javascript validation code needs the ID...


Yup, same here.
I use both, and for the same reasons.

Also, on occasion I have need of document.getElementsByName and arrays
of elements with the same name. Ids are supposed to be unique, so you
can't have a bunch of radio buttons, checkboxes, etc with the same id.
But they have to have the same name or they won't work right (radio
buttons, anyway).
Sometimes I want checkboxes instead od radio buttons because I want the
user to be able to choose multiples, but I want them with the same name
because they are really the same thing and get stored together server-
side.

--
--
~kaeli~
Suicide is the most sincere form of self-criticism.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #9
On Wed, 14 Jan 2004 12:05:50 +0100, Bertilo Wennergren
<be******@gmx.net> wrote:
Do look up the specification for XHTML 1.0.


But please ignore appendix C - or do all of it, including the bits
that require you to use XML PI's for stylesheets and also ensure you
avoid XML PI's.

The result being of course you can't use stylesheets, but that's not
too bad is it?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #10
It seems "Bertilo Wennergren" wrote in
comp.infosystems.www.authoring.html in article
<bu*************@news.t-online.com>:
I hesitated too, but finally I moved to "id"s on all of my pages.
I haven't had one single complaint.


It's not likely you would.

Very few Web surfers take the trouble to report broken links, even
ones that give "page not found". Since this type of broken link at
least lands on the right page, it's that much less likely to prompt
someone to report the problem.

Luckily only Netscape 4 is affected by this.

I still do <a name=...> because my script that generates tables of
contents expects <h2><a name="...">...</a></h2> and I haven't got
round to changing it to expect <h2 id="...">...</h2>. :-)

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #11
It seems "Spartanicus" wrote in comp.infosystems.www.authoring.html
in article
<ld********************************@news.spartanic us.utvinternet.ie>
Consider dropping the silly construct completely:
<h3 id="s5">Section 5</h3>
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote:
It's not silly if you need or wish to have your document working on
Netscape 4 too.

The poor browser does not jump to anchors defined by id
attributes, it needs <a name>.
I know, and don't care.


As Church Lady would say, "Well, isn't that _special_!"

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #12
On Wed, 14 Jan 2004 09:44:47 +0000, Spartanicus <me@privacy.net> wrote:
Consider dropping the silly construct completely:

<h3 id="s5">Section 5</h3>


I'd like to. Believe me. But older browsers cannot find ids from a link.
Gotta use a name for backward compatability, and in my situation, that's a
must.
Jul 20 '05 #13
On Wed, 14 Jan 2004 16:26:02 -0500, Stan Brown
<th************@fastmail.fm> wrote:
Very few Web surfers take the trouble to report broken links, even
ones that give "page not found". Since this type of broken link at
least lands on the right page, it's that much less likely to prompt
someone to report the problem.

Luckily only Netscape 4 is affected by this.


Problem is, the main reason I use this type of link is to allow users of
said Netscape to get from the top to the bottom, as they cannot view the
layout I've designed for more modern browsers. So normally the link is to
the same page they are on, and therefore does nothing if it references a
value that is an id and not a name.

For this situation, the only workaround is to continue the practice of
using a names until the old Netscape browsers have gone the way of the
dodo.
Jul 20 '05 #14
Neal wrote:

Problem is, the main reason I use this type of link is to allow users of
said Netscape to get from the top to the bottom, as they cannot view the
layout I've designed for more modern browsers. So normally the link is
to the same page they are on, and therefore does nothing if it
references a value that is an id and not a name.

For this situation, the only workaround is to continue the practice of
using a names until the old Netscape browsers have gone the way of the
dodo.


Unless your site has an unusually high concentration of NS4 users, it is
extinct. Browsers never really became extinct; they just fall into the
realm of being rarely used.

But since you have that great layout, can't you just arrange it so that
the content is first in NS4 and make it appear otherwise in newer browsers?

Jul 20 '05 #15
Jim Ley wrote:
On Wed, 14 Jan 2004 12:05:50 +0100, Bertilo Wennergren
<be******@gmx.net> wrote:
Do look up the specification for XHTML 1.0.


But please ignore appendix C - or do all of it, including the bits
that require you to use XML PI's for stylesheets and also ensure you
avoid XML PI's.

The result being of course you can't use stylesheets, but that's not
too bad is it?


I don't see anything that prohibits use of the <link> element to reference
external stylesheets. I _do_ see C.14 that requires use of a PI for
<style> elements, but it's usually better to use external stylesheets
anyway.
--
Jim Dabell

Jul 20 '05 #16
On Wed, 14 Jan 2004 16:52:30 +0000, Keith Bowes <do****@spam.me> wrote:
But since you have that great layout, can't you just arrange it so that
the content is first in NS4 and make it appear otherwise in newer
browsers?


Content is first. Purpose of links is to direct users to navigation, and
back to content from bottom of page. As some pages have multiple columns
of layout, this is a nice gesture, though certainly I could neglect them.

The target audience of this site works out to be, largely, people with
lesser computer skills and often old equipment - definitely not a
tech-savvy population. I've not done any sort of study, but I think it's
safe to assume the proportion of older browsers visiting this site is
higher than average. Plus it's for a non-profit, so we really don't want
to piss anybody off.
Jul 20 '05 #17
Stan Brown:
It seems "Bertilo Wennergren" wrote:
I hesitated too, but finally I moved to "id"s on all of my pages.
I haven't had one single complaint.

It's not likely you would. Very few Web surfers take the trouble to report broken links, even
ones that give "page not found". Since this type of broken link at
least lands on the right page, it's that much less likely to prompt
someone to report the problem.


Still I have a somewhat special audience, and many of my pages have
unique content with no alternative anywhere else. So I would actually
expect to get at least some complaints.

And I do get complaints about other things on my pages.

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #18
In article <op**************@news.rcn.com>, one of infinite monkeys
at the keyboard of Neal <ne*****@spamrcn.com> wrote:
According to the specs
(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> element
requires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to
4.01, it won't validate, it'll want to find the </A> tag.
Correct.
However, when I write a document containing, say, <a name="foo" /> it
validates in XHTML 1.0.
Correct. You've invoked an XML shorthand.
I'm obviously missing something here, as this confuses me somewhat. Does
the magical / make the empty a element valid? And doesn't this violate
http://www.w3.org/TR/xhtml1/#C_3 ?
Yes, it does violate Appendix C. But apart from being internally
inconsistent, Appendix C is in any case not normative, so violating
it isn't technically an error.
Nearest I can figure, it's recommending that although the tag will
validate, we still shouldn't do it in case a UA can't handle an empty a
element. Am I on the right track?
Yes, that's the purpose of Appendix C. But using XHTML makes life more
difficult for you, because it means validation will not spot the problem.

If you have a system that's generating empty <a>s and such things,
you can fix them by post-processing the output. See
http://apache.webthing.com/mod_xmlns/
for an Apache-based solution.
If not, feel free to correct me.


Congratulations on arriving at one of the fundamental problems with
the "thinking" behind XHTML.

--
Nick Kew

In urgent need of paying work - see http://www.webthing.com/~nick/cv.html
Jul 20 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
3
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns...
18
by: Tjerk Wolterink | last post by:
i have the following rule, <xsl:template match="br"> <br/> </xsl:template> This should convert all <br/> to <br/> but, my transformer transforms it all to
10
by: stanio | last post by:
As part of a thread on netscape.public.dev.css a guy (Gus Richter) tries to convince me <a><span></span></a> is not an empty anchor: > Of course the <p></p> is empty and in the following; > ...
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
2
by: Soren Kuula | last post by:
Hi, Is an empty XML document valid by any valid DTD? -- I guess it is .. after all, declarations apply just to elements in the document, and hey, if there are none, there can be nothing...
7
by: Alan Johnson | last post by:
It seems useful to be able to distinguish between an empty weak_ptr and one that has merely expired. For example: void f(weak_ptr<T> wp) { if (/* wp is empty */) { // Act is if a NULL...
16
by: Lastwebpage | last post by:
Hello, I am little surprised about the following: <a href="#" ... I found some lines about the href tag for a site should point to an name or in XHTML to an ID, but in both cases this seems to...
9
by: Dhiru1009 | last post by:
Hi guys, I am trying to build a user registration form using PHP and MYSQL but encountring a problem. When I click on submit with empty fields it adds records to database also it doesn't matter...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.