Путаницы здесь предостаточно.Оказывается, все правы.Вот факты:
1. CSS doesn't care much which you use, as far as actually applying
styling. ID's are technically faster for a browser rendering engine,
but other than the most extreme of circumstances you'll probably
never notice a speed difference
2. . JavaScript cares very much about ID's. It can be noticeably faster
for JavaScript to find an element by an ID. And this is where the
"uniqueness" is very important. JavaScript will only find the
"first" element with that ID, so if you have multiple on the page,
confusion may ensue.
3. ID's have an infinitely higher specificity value than classes. If
there is an element with an ID and a class and they both apply
styles, the styles applied by the ID will take precedence over the
styles applied by the class. This can be useful, this can be a
hindrance.
вот самый простой пример
#id { color: red; }
.class { color: green; }
Это просто атрибут, и это, казалось бы, произвольная разница в синтаксисе в зависимости от того, какой вы используете.Результаты предсказуемы:
<div id="id">Would be red</div>
<span id="id">Would be red</div>
<div class="class">Would be green</div>
<span class="class">Would be green</div>
ССЫЛКА