473,578 Members | 2,778 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 2451
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
5021
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
8878
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
2412
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
5901
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...
12
17094
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...
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
15942
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
4999
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
6116
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...
0
7850
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8291
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...
1
7874
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...
0
8150
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...
1
5664
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3786
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...
0
3801
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2293
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
0
1114
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.