Frontend Development

HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

Submitted by Avocat, , Thread ID: 61633

Thread Closed
Avocat
Lurker
Level:
0
Reputation:
0
Posts:
4
Likes:
0
Credits:
6
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

CryptAlchemy
Active Member
Level:
2
Reputation:
4
Posts:
276
Likes:
14
Credits:
0
02-12-2017, 07:32 PM
#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

Roskof
Novice
Level:
0
Reputation:
0
Posts:
33
Likes:
1
Credits:
1
07-12-2017, 12:29 AM
#4
A class can be recall, a contrario, an id can just call onetime .

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

LandRevenant
Coder
Prime
Level:
0
Reputation:
21
Posts:
146
Likes:
27
Credits:
2.93K
07-12-2017, 12:30 AM
#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

prankycrank
Novice
Level:
0
Reputation:
0
Posts:
20
Likes:
1
Credits:
4
07-12-2017, 04:18 AM
#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

vuchau
Lurker
Level:
0
Reputation:
0
Posts:
2
Likes:
0
Credits:
4
08-12-2017, 06:10 AM
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

vicky1360
Newbie
Level:
0
Reputation:
0
Posts:
15
Likes:
3
Credits:
72
28-12-2017, 01:04 AM
#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

thaiml888
Closed Account
Level:
0
Reputation:
0
Posts:
3
Likes:
0
Credits:
6
05-04-2018, 04:29 PM
#9
Thank you so much for sharing such wonderful scirpt, really appreciate that!

RE: HELP! DIFFERENCE BETWEEN DIV CLASS AND DIV ID

MrFortnite
Fulltime Member
Level:
0
Reputation:
36
Posts:
1.48K
Likes:
53
Credits:
758
06-04-2018, 11:12 PM
#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: 1 Guest(s)