ID is used to uniquely identify an element(a unique identifier). It is particularly useful when you want only 1 element to have specific styling. Another use is in JavaScript. JS uses getElementbyID to call upon an element to perform specific tasks. Class is used to define styling for HTML elements. It can be used multiple times, meaning that multiple elements can use the same class to style.
class is used to customize both boxes at the same time(i.e both boxes are having same height and Width) and id is used to customize each box specifically (i.e each box are are having different colour that was possible because of id ) if you use (class) for background colour changes both boxes will be having same background colour as both are having same class name. hope so i made it clear to you?
Bro Code
Box 1
Box 2
/* style.css */
body{
margin: 0px;
}
.box{
border: 5px solid;
font-size: 5em;
width: 250px;
height: 250px;
margin-top: 50px;
margin-right: 50px;
margin-bottom: 50px;
margin-left: 50px;
}
#box1{
background-color: hsl(0, 100%, 60%);
}
#box2{
background-color: hsl(189, 100%, 55%);
}
bro is a legend
M9wed had sat, kayshr7 khir men les profs
@@samisado6331 check point l m4arba li 4aydozo hna
Bro visited his friend
@@ElysiumGresit lol
@@imrane206 margin w padding w font-size w lakhra nsitha ba9i mafhmtch logique fihom
Wow you help me alot understanding stuff about html and css. Thanks alot!
Nice Video. margin-left: auto; with margin-right: auto; is also a good combination.
it's clear and easy to understand the usage.
Really helpful for understanding margin concept
I like the way you have expalined I am starting to learn it, thanks for your short and clear explanation.
Thanks man your videos have really helped me to master css. Sincerely you are best youtuber when it comes to explaining any code related stuff.
love your sharing. Short & easy to understand
Thank You So Much!!!! This Is So UseFull For Us!!!!
video của bạn rất hay
Great thank you
Love you Bro I missed you too much😭🤧
Genius of the Century
THIS IS GOOD
thanks bro, it helped me
Thank you soo much
Can you please explain the margin: inherent
ty brother
Couldn't have said enough thank you
Hello I just want to ask. what is the difference of class and id? thank youu
I think we use id to track / find element with java script like (get element by id)
There isn't really a difference
I think class can be used for multiple stuff at the same time but ID not? Im not sure
ID is used to uniquely identify an element(a unique identifier). It is particularly useful when you want only 1 element to have specific styling.
Another use is in JavaScript. JS uses getElementbyID to call upon an element to perform specific tasks.
Class is used to define styling for HTML elements. It can be used multiple times, meaning that multiple elements can use the same class to style.
@@TheRetiredBatman Your're right.
Why do you use class and id within the same div again?
class is used to customize both boxes at the same time(i.e both boxes are having same height and Width)
and
id is used to customize each box specifically (i.e each box are are having different colour that was possible because of id )
if you use (class) for background colour changes both boxes will be having same background colour as both are having same class name.
hope so i made it clear to you?
Was that a Shrek reference? 😉