td table data and the attribute name

M

marcwentink

I am checking html against:

http://validator.w3.org/check

and it seems to complain about:

<td class="stctd" name=tdbsgroep id=tdbsgroep>

"Line 659 column 34: there is no attribute "NAME"."

is that correct, td does not have an attribute name?

I see this all over the place in the old code I am changing.
(Which not necesarelly means this is correct of course.)
 
S

Steve Pugh

I am checking html against:

http://validator.w3.org/check

and it seems to complain about:

<td class="stctd" name=tdbsgroep id=tdbsgroep>

"Line 659 column 34: there is no attribute "NAME"."

is that correct, td does not have an attribute name?

Correct. You can check the spec yourself:
http://www.w3.org/TR/html401/struct/tables.html#edef-TD
I see this all over the place in the old code I am changing.
(Which not necesarelly means this is correct of course.)

Is it being used at all in your code? By some back end process (in
which case strip it out when it's served) or by some JavaScript
(rewrite the JS to use id or class instead)? Because otherwise it's
just pointless bloat.

Steve
 
A

APT

I am checking html against:

http://validator.w3.org/check

and it seems to complain about:

<td class="stctd" name=tdbsgroep id=tdbsgroep>

"Line 659 column 34: there is no attribute "NAME"."

is that correct, td does not have an attribute name?

I see this all over the place in the old code I am changing.
(Which not necesarelly means this is correct of course.)

It may be confused that the "name" and "id" are the same. Both names and IDs
should have unique names that are only used once per document.

Try changing the ID name and see if the error is still there.
 
S

Steve Pugh

APT said:
It may be confused

No it's not confused.
that the "name" and "id" are the same.

On some elements they have to be the same. On other elements they may
or may not be the same. There is no element in HTML where name and id
must be different.
Both names and IDs
should have unique names that are only used once per document.

Ids must be unique within the document, but there are cases where name
can be the repeated.
Try changing the ID name and see if the error is still there.

It will be. The problem is with the name attribute itself, not with its
value.

Steve
 
M

marcwentink

Steve:
Is it being used at all in your code?

Not at all.

The person who wrote it just assumed it should have a name and an id.
The id is used, the name not. But why should td have an id, but not a
name? Why is there a name and also an id attribute anyway?

The only reason I can find is that some elements have one name, and a
few sort of subelements, by id. And then you can use:
getElementsByName, note the plurial "Elements".
 
S

Steve Pugh

The person who wrote it just assumed it should have a name and an id.
The id is used, the name not. But why should td have an id, but not a
name? Why is there a name and also an id attribute anyway?

name was used in earlier versions of HTML for a selection of different
purposes. Look at the attributes index for HTML 4 and you see that
there are 11 different definitions for the name attribute depending on
which element it is used on.
http://www.w3.org/TR/html401/index/attributes.html

So from HTML 4 onwards, the id attribute is used to uniquely identify
an element for the purposes of scripting and linking; and the name
attribute is only really used for form elements now.
The only reason I can find is that some elements have one name, and a
few sort of subelements, by id. And then you can use:
getElementsByName, note the plurial "Elements".

Yep, radio buttons are the classic example. A group of radio must have
the same name, but each individual radio button can have a unique id as
well.

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top