Forum Moderators: open

Message Too Old, No Replies

Forms: name and id problems

xhtml validator problem

         

webgirl

9:38 am on Sep 18, 2003 (gmt 0)

10+ Year Member



Hi everyone. I've run into a bit of a problem with the old W3C validator - everything is working great apart from a contact page I've built. In this form I use both name and id and have given them the same values, however the validator is failing the page saying that the value is already being used in that tag (by name, which is before id).

I just wanted to check whether it's okay to give id a different value or another way round this? I was always under the impression that they should have the same value... Help! I'm a bit confused!....

Thanks in advance for any help you can give me :)

garann

4:23 pm on Sep 18, 2003 (gmt 0)

10+ Year Member



I think you can safely get rid of name and just use id. When you submit the form, I believe you can refer to the form field's value by the name or the id. You can also give the attributes different values, but it might be overkill and I'm not sure how the validator responds to that.

Good luck!
g.

MonkeeSage

3:57 am on Sep 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The id Attribute replaces the Name Attribute

HTML 4.01 defines a name attribute for the elements a, applet, frame, iframe, img, and map. In XHTML the name attribute is deprecated. Use id instead.

This is wrong:
<img src="picture.gif" name="picture1" />


This is correct:
<img src="picture.gif" id="picture1" />


Note: To interoperate with older browsers for a while, you should use both name and id, with identical attribute values, like this:
<img src="picture.gif" id="picture1" name="picture1" />


IMPORTANT Compatibility Note:

To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol.
(Cite [w3schools.com], emphasis original).

Also, even in HTML 4...

name = cdata [CS]
This attribute names the current anchor so that it may be the destination of another link. The value of this attribute must be a unique anchor name. The scope of this name is the current document. Note that this attribute shares the same name space as the id attribute.
(Cite [w3.org], emphasis added).

Try garann's suggestion and you should be good to go. :)

Jordan

Mohamed_E

5:19 am on Sep 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Interesting, this is the first I have heard of ID used as a target anchor for links (I use HTML, not XHTML). A quick look at the htmlhelp site [htmlhelp.com] showed:

HTML 4.0's ID attribute is intended to eliminate the need for A NAME. The ID attribute can be used with almost any element to define a link destination, so that the following could be used in place of the previous example:

<H1 ID=foo>My heading</H1>

However, browser support for ID link destinations is very poor, so A NAME will be needed for quite awhile.

What is the current status of browser support for ID? Is there any point in converting NAME to ID in an HTML context?

webgirl

9:20 am on Sep 22, 2003 (gmt 0)

10+ Year Member



Great, thanks for your help guys!