473,659 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2459
Neal <ne*****@spamrc n.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">Sectio n 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.n et> <http://www.bertilow.co m>
Jul 20 '05 #3
Spartanicus <me@privacy.net > wrote:
Consider dropping the silly construct completely:

<h3 id="s5">Sectio n 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">Sectio n 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.n et> <http://www.bertilow.co m>
Jul 20 '05 #5
"Jukka K. Korpela" <jk******@cs.tu t.fi> wrote:
Consider dropping the silly construct completely:

<h3 id="s5">Sectio n 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.tu t.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*****@spamrc n.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.c o.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.getEle mentsByName 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.n et> 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.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #10

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

Similar topics

1
5025
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
3
8887
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 a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
18
2418
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
5903
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; > <div><a href="#"><span id="header"></span></a></div> > The div has an anchor as content. > *The anchor has span as content*. (Your erroneous contention is that > <a><span></span></a> is an empty anchor.) > The span, on the other hand, is empty,...
12
17098
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. This is okay in some cases (such as <tbody>), but problematic for other tags (such as <option>). Some tags (td, th, ...) do not produce warnings when they are empty.
2
1194
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 wrong... Soren
7
15959
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 pointer was passed. } else
16
5005
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 be not valid name="#" or id=""... And I wonder why the online validator allow this in all cases.DOCUMENT types.
9
6121
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 what information I put it always add records to database when I click on submit. What can I do to make sure user will not be able to add records to database until he enters the right information? I am posting my code for you guys to have a look...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.