Forum Moderators: open

Message Too Old, No Replies

XHTML validator

Repeating <div> id attribute on a page

         

Birdman

4:21 pm on Aug 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello WW. I'm trying to get a page to validate for xhtml. I used CSS for positioning with <div>s. I have used the same <div> id three times on the page but closed them before starting another. Validator says "attribute id="my id" already described. Am I not allowed to use the same <div>id attribute more than once on a page? Any advice will be appreciated.

<added>It displays great on Opera and IE</added>

Knowles

4:30 pm on Aug 14, 2002 (gmt 0)

10+ Year Member



This might help you. An id is used to reference a unique element. [webmasterworld.com] (Taken from rewboss' reply)

Birdman

4:56 pm on Aug 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you Knowles:) That did help. Of course now I'm trying to put the page back together but I'm close. I smell validation!

Knowles

5:02 pm on Aug 14, 2002 (gmt 0)

10+ Year Member



Cant you just replace the id with class? Then change the CSS from # to .?

<added>Oh yeah glad that helped :)</added>

Birdman

5:04 pm on Aug 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ahhhhh, validation :) :) :) :)
You learn something new every day.

Today's lesson:
"id" attributes are only allowed to occur once per page but "class" attributes may be repeated as many times as you wish.

>>Cant you just replace the id with class? Then change the CSS from # to .?

That's what I did and as I quickly notices, I had the attribute "name" repeated on other elements in my CSS. Just changed a few names and it everything fell back in place. Thanks again:)

papabaer

6:02 pm on Aug 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to give a hint of the power behind #id's -
I have written many pages where not a single .class is declared. I style my core elements and unique id's.

Treat the #id with the respect it deserves: it is unique!