Probably I wasn't clear here.
Of course, having multiple elements with the same ID brakes the meaning of
the ID, as you pointed.
And yes, strictly speaking, this will make the document invalid, because it
violates specification.
But in practice things won't stop working if you put multiple elements with
the same ID on a page. You won't see any errors, etc.
The only side-effect will happen is that you won't be able to get second,
third, etc. elements by using ID selectors in JS.
But CSS styling rules will still work. In the example below you will see
content of both divs in UPPERCASE, but jQuery('#id1').length will yield 1
(this will be the first element in the order of appearance in dom), also
document.getElementById("id1") will return first element:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";>

<head>

    <script>jQuery.noConflict();</script>



    <style>

        #id1 {text-transform: uppercase;}

    </style>

</head>

<body>


    <div id="id1">First element</div>

    <div id="id1">Second element</div>


    <a href="javascript:alert(jQuery('#id1').length)">Count</a>


</body>

</html>


On Sat, Sep 21, 2013 at 12:07 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Thu, 19 Sep 2013 08:15:18 -0300, Dmitry Gusev <dmitry.gu...@gmail.com>
> wrote:
>
>  And by the way, this is not illegal to have multiple elements with the
>> same id
>>
>
> Both HTML and XML forbid more than one element having the same id [1].
> Otherwise, it wouldn't be called an id. ;) If you need to find more than
> one element, you should use another attribute for it. In HTML, usually the
> "class" attribute.
>
> http://www.w3.org/TR/REC-**html40/struct/global.html#**adef-id<http://www.w3.org/TR/REC-html40/struct/global.html#adef-id>
> "This attribute assigns a name to an element. This name must be unique in
> a document."
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to