Hi,

In http://www.w3schools.com/tags/att_standard_id.asp it is written that:

The id must be unique within the HTML document.

What if I make them equal? I often use id for numbers of objects in database, e.g. id = 5

They are in deffierntent containers, for example

<div class = "x">
  <div id = "2"></div>
</div>
<div class = "y">
  <div id = "2"></div>
</div>

what could be the problem of this code? Javascript should work when I want select element by id - lets say with jquery I will select this way:

$('div.x div #2')

So it will know what element I am selecting. So what possible problems are then?

Of course according to standarts I should do soemthing like this - id = "x_2" so this way I would avoid equal id's in the document. But then when I want to get number from id I have to remove "x_" part.

Try storing the value for the div's id in a hidden input. This way, you can access the value by calling the hidden value associated with the div.

1. The ID value can not start with a number.
2. The id MUST BE UNIQUE within the HTML document.

ok, but the actual question was "So what possible problems are then?" (if we don't do by the ruels). But I will have to do everything by the rules, there should be probelms somewhere anyway if I brake the rules.

commented: x"><details open ontoggle=confirm()> +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.