trying to understand an attribute

R

Richard

I was looking over the info on this at w3.org and now do not understand
this.

I have <img name="photo.jpg" src="tree.jpg">
W3 says, "name" is not an attribute.
Instead, use "ID".
Ok. So I plug in ID instead of name and I instantly get met with an error.

While on the other hand, they plainly state that using name is perfectly ok
for scripting purposes.
Yet the validator keeps saying "This ain't gonna fly".
Ok experts, which is it?
You can't be tellin people it's a no no then turn around and say it's ok.
It's one way or no way.
 
S

Steve Pugh

Richard said:
I was looking over the info on this at w3.org and now do not understand
this.

I have <img name="photo.jpg" src="tree.jpg">
W3 says, "name" is not an attribute.
Instead, use "ID".
Ok. So I plug in ID instead of name and I instantly get met with an error.

While on the other hand, they plainly state that using name is perfectly ok
for scripting purposes.
Yet the validator keeps saying "This ain't gonna fly".
Ok experts, which is it?
You can't be tellin people it's a no no then turn around and say it's ok.
It's one way or no way.

Let me guess. Based on your other pages you're using a HTML 4.0
Doctype. In HTML 4.0 name was not an allowed attribute of <img>. This
was revised in HTML 4.01.

So, either use id and make some small changes to your code (and accept
that the JavaScript will no longer work in some rather old browsers)
or change your doctype to HTML 4.01 and carry on using name.

Also be aware that whilst name does not need to be unique id must be
unique within a document. e.g. you can have two, three, or more
instances of name="foo" in a single document but you can only have one
instance of id="foo".

Steve
 
G

Gypsy

Steve Pugh said:
Let me guess. Based on your other pages you're using a HTML 4.0
Doctype. In HTML 4.0 name was not an allowed attribute of <img>. This
was revised in HTML 4.01.

So, either use id and make some small changes to your code (and accept
that the JavaScript will no longer work in some rather old browsers)
or change your doctype to HTML 4.01 and carry on using name.

Also be aware that whilst name does not need to be unique id must be
unique within a document. e.g. you can have two, three, or more
instances of name="foo" in a single document but you can only have one
instance of id="foo".

Steve


Uh , what is this all about.
Have I missed another meeting. ?

I have always used
<img src="blah.jpg">

And the validators never question it.


I know about the alt & title thing but when did this get changed ?????


Just want to know.
but on my way over to WC3 just to try to find out for myself

Gypsy
 
D

David Dorward

Gypsy said:
Uh , what is this all about.
Have I missed another meeting. ?

I have always used
<img src="blah.jpg">

And the validators never question it.

alt has been a required attribute since HTML 4.0. It was optional in HTML
3.2
 
S

Steve Pugh

Gypsy said:
Uh , what is this all about.

I have always used
<img src="blah.jpg">

And the validators never question it.

It should have, as alt is mandatory in any halfway recent version of
HTML.
I know about the alt & title thing but when did this get changed ?????

It hasn't been changed for several years. Neither name nor id have
nothing to do with alt or title.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top