+ 4

Class and Id

how do you know when you use a class or id?

10th Feb 2017, 7:48 PM
Cltnbatchelor
Cltnbatchelor - avatar
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.
10th Feb 2017, 9:38 PM
Samuele Sacchetti
Samuele Sacchetti - avatar
+ 2
thanks that helps out alot.
10th Feb 2017, 9:41 PM
Cltnbatchelor
Cltnbatchelor - avatar
+ 1
well how do you know to use a class attribute or an ID? aren't they generally same thing?
10th Feb 2017, 9:14 PM
Cltnbatchelor
Cltnbatchelor - avatar
+ 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 ?
10th Feb 2017, 9:21 PM
Samuele Sacchetti
Samuele Sacchetti - avatar
+ 1
so ID is for say a nav or footer and a class can be many boxes of description on the website,?
10th Feb 2017, 9:23 PM
Cltnbatchelor
Cltnbatchelor - avatar
0
what do you mean ? You mean the job that they do ?
10th Feb 2017, 9:13 PM
Samuele Sacchetti
Samuele Sacchetti - avatar