Two HTML elements with same id attribute: How bad is it really?
Posted
by
danludwig
on Programmers
See other posts from Programmers
or by danludwig
Published on 2011-12-27T17:23:06Z
Indexed on
2012/09/04
9:48 UTC
Read the original article
Hit count: 166
Just browsing the google maps source code. In their header, they have 2 divs with id="search" one contains the other, and also has jstrack="1" attribute. There is a form separating them like so:
<div id="search" jstrack="1">
<form action="/maps" id="...rest isn't important">
...
<div id="search">...
Since this is google, I'm assuming it's not a mistake.
So how bad can it really be to violate this rule? As long as you are careful in your css and dom selection, why not reuse id's like classes? Does anyone do this on purpose, and if so, why?
© Programmers or respective owner