+ 4
Class and Id
how do you know when you use a class or id?
6 Respostas
+ 2
you can attribute the class or id attributes to everyone you want to style. example:
<p id="one"> Hello </p>
css:
#one {
font-size: 30px;
}
<p class="first"> Hello </p>
<p> The first time </p>
<p> The second </p>
<p class="first"> Hello </p>
css:
p.first {
font-size: 22px;
}
With ids you cant do this :
<p id="second"> Hello </p>
<p id="second"> Hello </p>
The id is single, onyl for one element
Instead classes is like a group of elements.
+ 2
thanks that helps out alot.
+ 1
well how do you know to use a class attribute or an ID? aren't they generally same thing?
+ 1
no they aren't. because when you go to style them on css they aren't the same. The class is like a classroom where there so students. Instead an id is like a single student. When you go to css, with the class attribute you can style more tags than id. Id is for only one thing. Do you understand ?
+ 1
so ID is for say a nav or footer and a class can be many boxes of description on the website,?
0
what do you mean ? You mean the job that they do ?