473,493 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Replacing name with id

I have a bunch of old web pages now in HTML 4.01 Strict I update every
now and then with revised material. They were written back when using <a
name=" was the normal method of including an anchor. Most of the
internal anchors follow a very standard layout, and are associated with
an h3 heading.

I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors? I gather that all recent browsers
work fine with id on any element as an anchor. I also gather that name
is deprecated in one or another of the XHTML versions I am not yet using
due to IE. I did think it might be handy in future to be a little closer
to XHTML, if I do decide I am tired of catering to IE.

I would be making other global changes to all the pages, so this change
simply adds another few sets of global replacements to my work.

--
http://www.ericlindsay.com
Jan 6 '08 #1
16 1963
Scripsit Eric Lindsay:
I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?
Not really, unless you're doing some scripting that needs id attributes
for the elements.
I gather that all recent browsers
work fine with id on any element as an anchor.
Right. We can virtually ignore Netscape 4 these days.
I also gather that name
is deprecated in one or another of the XHTML versions
That's irrelevant. (Technically, it's deprecated for <aelements, but
not for all elements. The reason for the deprecation, as you know, is
that the id attribute is more logical and XML-like for the purpose.)
I did think it might be handy in future to be a
little closer to XHTML, if I do decide I am tired of catering to IE.
It doesn't matter. If you ever switch to XHTML, you will have several
changes to be made anyway, and making _this_ change is not really
special. You might use id for new pages, just as you might use
lowercase-only element names, because these are allowed in classic HTML
as well as required in XHTML. But changing existing <a name= ...>
anchors or existing use of uppercase in element names is just pointless.
_Any_ change, no matter how automated, involves a risk of errors; some
assumptions may just fail, and your regular expression (or whatever) may
somehow miss some special case and produce a mess. It's better to take
risks only when there is something to be won, i.e. when performing the
(full) conversion to XHTML for some real reason.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 6 '08 #2
Sun, 06 Jan 2008 14:45:14 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
I have a bunch of old web pages now in HTML 4.01 Strict I update every
now and then with revised material. They were written back when using <a
name=" was the normal method of including an anchor. Most of the
internal anchors follow a very standard layout, and are associated with
an h3 heading.

I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?
I can't think of any. IIRC, a very old version of Netscape honored
name= but not =id, but that's been quite a few years now. Just be
careful in your script to remove the associated </a>, even if it's
not on the same line.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Jan 6 '08 #3
Scripsit Jukka K. Korpela:
Scripsit Eric Lindsay:
>I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?

Not really, unless you're doing some scripting that needs id
attributes for the elements.
Oops, I seem to have misread the question. I answered the question "in
there any reason...".

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 6 '08 #4
In article <MP************************@news.individual.net> ,
Stan Brown <th************@fastmail.fmwrote:
Sun, 06 Jan 2008 14:45:14 +1000 from Eric Lindsay
I was wondering whether there was any reason not to change these <a
name=" anchors to <h3 id=" anchors?

I can't think of any. IIRC, a very old version of Netscape honored
name= but not =id, but that's been quite a few years now. Just be
careful in your script to remove the associated </a>, even if it's
not on the same line.
Many thanks. That old Netscape was probably what I was recalling as a
possible reason not to make the changes.

Thanks for mentioning the associated </a>. I did handle that correctly,
for once. The first few sets of changes I made did reveal that some of
my earlier pages were less like the later ones than I originally
expected. Perils of not using a program to generate my web pages.

There were some errors. The mess that Jukka (correctly) predicted did
occur, however only visible in a dozen or so pages. I had no doubt I
would find other flaws when I validated some of the pages again.

The big error was that id can not start with a number, and all my names
were actually automatically generated dates like 20080107a 20080107b and
so on. I wonder why that did not throw up a validation error when I had
<a name="20080107a" I had never noticed that I had thousands of such
name errors.

I can certainly see why Jukka cautions against taking risks with regular
expression changes over heaps of files. However I only seem to improve
by running up against vast numbers of my past errors.

--
http://www.ericlindsay.com
Jan 7 '08 #5
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
The big error was that id can not start with a number, and all my names
were actually automatically generated dates like 20080107a 20080107b and
so on. I wonder why that did not throw up a validation error when I had
<a name="20080107a" I had never noticed that I had thousands of such
name errors.
I used similar names to anchor revision points in my pages. When I
switched to IDs I got the same validation errors you did, so I
prepended a U to them.

I remember researching the issue, but it was a few years ago. I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Jan 8 '08 #6
Stan Brown wrote:
>
I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.
http://www.w3.org/TR/html401/types.html#type-id

I don't know if the validator ever checked values on the name attribute,
though.
--
Berg
Jan 8 '08 #7
in comp.infosystems.www.authoring.html, Stan Brown wrote:
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
The big error was that id can not start with a number, and all my names
<a name="20080107a" I had never noticed that I had thousands of such
When I switched to IDs I got the same validation errors you did, so I
prepended a U to them.
Which then breaks all external links.

--
Lauri Raittila <http://www.iki.fi/lr>
Jan 9 '08 #8
Stan Brown wrote:
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
>The big error was that id can not start with a number, and all my names
were actually automatically generated dates like 20080107a 20080107b and
so on. I wonder why that did not throw up a validation error when I had
<a name="20080107a" I had never noticed that I had thousands of such
name errors.

I used similar names to anchor revision points in my pages. When I
switched to IDs I got the same validation errors you did, so I
prepended a U to them.

I remember researching the issue, but it was a few years ago. I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.
No a NAME and ID must start with a letter [A-Z,a-z]

http://www.w3.org/TR/html4/types.html#type-name

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jan 9 '08 #9
Lauri Raittila wrote:
in comp.infosystems.www.authoring.html, Stan Brown wrote:
>Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
>>The big error was that id can not start with a number, and all my names
<a name="20080107a" I had never noticed that I had thousands of such
>When I switched to IDs I got the same validation errors you did, so I
prepended a U to them.

Which then breaks all external links.
How? If www.example.com/somepage.html#00021 is a invalid URL

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jan 9 '08 #10
in comp.infosystems.www.authoring.html, Jonathan N. Little wrote:
Lauri Raittila wrote:
in comp.infosystems.www.authoring.html, Stan Brown wrote:
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
The big error was that id can not start with a number, and all my names
<a name="20080107a" I had never noticed that I had thousands of such
When I switched to IDs I got the same validation errors you did, so I
prepended a U to them.
Which then breaks all external links.
How? If www.example.com/somepage.html#00021 is a invalid URL
But it works. Sure it would be better to have done it correctly in first
place, but why fix something that has been working before, especially
when side effect is to break something?

--
Lauri Raittila <http://www.iki.fi/lr>
Jan 9 '08 #11
Lauri Raittila wrote:
in comp.infosystems.www.authoring.html, Jonathan N. Little wrote:
>Lauri Raittila wrote:
>>in comp.infosystems.www.authoring.html, Stan Brown wrote:
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
The big error was that id can not start with a number, and all my names
<a name="20080107a" I had never noticed that I had thousands of such
When I switched to IDs I got the same validation errors you did, so I
prepended a U to them.
>>Which then breaks all external links.
>How? If www.example.com/somepage.html#00021 is a invalid URL

But it works. Sure it would be better to have done it correctly in first
place, but why fix something that has been working before, especially
when side effect is to break something?
It "works" because of the browser's error correction, but no guarantee
that it will continue to work or with every browser. Anyway what is the
big deal? The situation only applies to the fragment, the external links
will still connect to the proper page. As long as you have reasonable
sized pages and not one of those "scroll-o-death" pages, folks will find
the info. What you don't want to beak is the link to the page.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jan 9 '08 #12
..oO(Jonathan N. Little)
>Stan Brown wrote:
>I remember researching the issue, but it was a few years ago. I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.

No a NAME and ID must start with a letter [A-Z,a-z]

http://www.w3.org/TR/html4/types.html#type-name
In most cases the 'name' attribute is of type CDATA, not NAME.

Micha
Jan 9 '08 #13
Michael Fesser wrote:
.oO(Jonathan N. Little)
>Stan Brown wrote:
>>I remember researching the issue, but it was a few years ago. I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.
No a NAME and ID must start with a letter [A-Z,a-z]

http://www.w3.org/TR/html4/types.html#type-name

In most cases the 'name' attribute is of type CDATA, not NAME.

Micha
"For some HTML 4 attributes with CDATA attribute values, the
specification imposes further constraints on the set of legal values for
the attribute that may not be expressed by the DTD."

....

"ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
followed by any number of letters, digits ([0-9]), hyphens ("-"),
underscores ("_"), colons (":"), and periods (".")."
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jan 9 '08 #14
Wed, 9 Jan 2008 17:23:07 +0200 from Lauri Raittila
<la***@raittila.cjb.net>:
in comp.infosystems.www.authoring.html, Stan Brown wrote:
Mon, 07 Jan 2008 22:34:17 +1000 from Eric Lindsay
<NO*************@ericlindsay.com>:
The big error was that id can not start with a number, and all my names
<a name="20080107a" I had never noticed that I had thousands of such
When I switched to IDs I got the same validation errors you did, so I
prepended a U to them.

Which then breaks all external links.
I'm not going to shed any tears over that. The anchors were to
various passages modified on particular dates, and the only place it
makes sense to reference them is from the change log, which is on the
same page.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Jan 9 '08 #15
Michael Fesser wrote:
.oO(Jonathan N. Little)
>Michael Fesser wrote:
>>.oO(Jonathan N. Little)

Stan Brown wrote:

I remember researching the issue, but it was a few years ago. I can't
remember whether names starting with numerics were legal in name=, or
were illegal but just not found by the validator.
No a NAME and ID must start with a letter [A-Z,a-z]

http://www.w3.org/TR/html4/types.html#type-name
In most cases the 'name' attribute is of type CDATA, not NAME.

Micha
"For some HTML 4 attributes with CDATA attribute values, the
specification imposes further constraints on the set of legal values for
the attribute that may not be expressed by the DTD."

Correct. But are there such constraints mentioned in the spec regarding
the 'name' attribute on anchors? Sections 12.2 and 12.2.1 say nothing
about the allowed chars (except for using only ASCII chars) or what kind
of char the name should start with.

Then there's also 12.2.3, which says:

| Because of its specification in the HTML DTD, the name attribute may
| contain character references. Thus, the value D&#xfc;rst is a valid
| name attribute value, as is D&uuml;rst . The id attribute, on the
| other hand, may not contain character references.
True but the still does not allow a NAME or ID to begin with [0-9]

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jan 10 '08 #16
..oO(Jonathan N. Little)
>Michael Fesser wrote:
>>
Then there's also 12.2.3, which says:

| Because of its specification in the HTML DTD, the name attribute may
| contain character references. Thus, the value D&#xfc;rst is a valid
| name attribute value, as is D&uuml;rst . The id attribute, on the
| other hand, may not contain character references.

True but the still does not allow a NAME or ID to begin with [0-9]
Yes, but the 'name' attribute of an anchor is not a NAME token, it's a
CDATA. So the question remains, whether a name starting with a digit is
valid or not.

For me it doesn't matter anyway, it's just out of interest.

Micha
Jan 10 '08 #17

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

Similar topics

8
1586
by: jamesfin | last post by:
Dear XMLers, Please guide me... I have a simple xml file... <URLTest>
1
1474
by: Søren Schimkat | last post by:
Hi everyone I´m having some problems with replacing one form with another. The first problem is the the replace function only works once - and the second problem is that the thml code dosn´t get...
2
2029
by: thehuby | last post by:
Isn't inserting good data and getting it out of a db a pain in the a$$? I am going to be using the Markdown text to HTML parser (http://daringfireball.net/projects/markdown/dingus) for creating...
3
2113
by: Muntz | last post by:
Hi - we are MSDN Enterprise subscribers, our no-spam address is munter@computershare.com We are currently trying to replace a SoapToolkit web-service with a .NET WebMethod implementation, but...
6
24202
by: tentstitcher | last post by:
Hi all: I have a source xml document with an element of type string. This element contains something like the following: <stringData> &lt;Header&gt; &lt;Body&gt; </stringData> I would like to apply an...
2
6528
by: David | last post by:
Sent this to alt.php a couple of days back, but doesn't look like I'll get an answer, so trying here. I'm trying to convert a script to use friendly URLs, I've done this before, but my PHP...
9
24728
by: Prakash Singh Bhakuni | last post by:
am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening...
1
4488
by: patelgaurav85 | last post by:
Hi, I want to convert xml in one format into another xml format shown below Input xml : <Name> <Name1> <Name11>Name11</Name11> <Name12>Name12</Name12>
1
2315
by: susan10 | last post by:
Im new to Coldfusion, and here is what i would like to do: I'm using a html-editor on one cfm-page, and saving the text in a database: --mytext written i the html-editor ----------------------...
29
19135
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
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
5453
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,...
1
4889
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...
0
4579
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...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
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...

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.