Does browser treat "id" and "class" as the same, even though they have different meaning?

Recommended Answers

All 3 Replies

Member Avatar

Depends what you're using them for. As a rule of thumb each 'id' can only be declared once, whereas you can have as many identical 'class' values as you want on a page. The id and class are used extensively as 'hooks' for css and javascript.

In CSS, 'ids' are denoted with a # symbol before the id value and classes with a . symbol. Javascript frameworks such as jQuery have also gone for this notation.

commented: beat me to it... again :P +1
commented: Very clear and straight to the point :) +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, learning, and sharing knowledge.