Frontend Development

HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

Submitted by Avocat, , Thread ID: 61633

Thread Closed
21-11-2017, 11:04 PM
#1
Hi all, I'm searching the right difference between the tag div class and the tag div id, I know only that the class in the css is called with the dot (.) and the id with the #...

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#2
you can read the detail about class and id here https://css-tricks.com/the-difference-be...and-class/

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#3
These two attributes are quite easy to mix up.

The class is something that will be used repeatedly, while the id is something that will only be used to identify a div ONCE.

Hope this helps! Smile

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#4
A class can be recall, a contrario, an id can just call onetime .

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#5
Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "." id is used when we have to apply CSS property to one attribute only

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#6
The difference is quite obvious usually ID is always unique so can use it only one element, but the class refers to a group with similar properties so you can use it with multiple elements.

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

This post was last modified: 08-12-2017, 06:10 AM by vuchau
#7
07-12-2017, 04:18 AM
prankycrank Wrote:
The difference is quite obvious usually ID is always unique so can use it only one element, but the class refers to a group with similar properties so you can use it with multiple elements.

Great, simple and full of meaning.

25-11-2017, 09:09 PM
luluxxx Wrote:
you can read the detail about class and id here https://css-tricks.com/the-difference-be...and-class/

Thanks for your shared.

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#8
Use ID to identify/manipulate/target a single element and Class to manipulate/target all elements with similar properties or actions.

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#9
Thank you so much for sharing such wonderful scirpt, really appreciate that!

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

#10
Class is for styles and references to stylesheets, don't use these as they're not unique, unless of course you are trying to style multiple elements (if not just one element) with the same stylings.... Hence: Cascading Style Sheet.
ID's are unique and meant to only be used by one element, such as clicking a button. Clicking the second button should NOT have the same ID as they'll both do the same thing, or will activate things that are meant to change the buttons style for example, and they both end up changing. These should be unique.
"It never hurts to keep looking for sunshine" - A. A. Milne

Users browsing this thread: 3 Guest(s)