PDA

View Full Version : Reusing the same id in Xhtml strict


Mhtml
07-15-2003, 07:14 PM
How can I reuse the same id for elements and validate my code as xhtml strict?

Problem is that you can't redefine elements using the same id and my menu script I wrote uses the id to differ between a menu heading and it's child nodes.

Although you won't need my code I'll post it anyway.

<ol id="Menu">
<li id="menuTitle">Section</li>
<li><a href="#">Child node</a></li>
<li><a href="#">Child node</a></li>
<li><a href="#">Child node</a></li>

<li id="menuTitle">Section</li>
<li><a href="#">Child node</a></li>
<li><a href="#">Child node</a></li>
</ol>
The purpose is to be as clean as possible and keep javascript separate from the document. I only specify the menu and each section header and use dom to find child nodes of the sections which are really siblings.

Spookster
07-15-2003, 07:24 PM
Shame on you. Wait til jkd or brothercake sees that. :eek:

You shouldn't be giving multiple elements the same id. Shouldn't you just define a class for those and assign the class to them all?

brothercake
07-15-2003, 07:35 PM
hee hee :) .. shame on you Michael :p

What's wrong with class? It's easy to prototype a getElementsByClassName function you can find them with ...

Mhtml
07-15-2003, 10:06 PM
W00t, thankyou. :)