Class and id | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Class and id

what are class and id in css

2nd Aug 2017, 4:12 PM
raj soni
raj soni - avatar
2 Answers
0
Goto your CSS course: CSS Fundamentals CSS Basics CSS Rules and Selectors (3/6) Id and class selector (3rd tab) study the course contents again: id and class Selectors id selectors allow you to style an HTML element that has an id attribute, regardless of their position in the document tree. Class selectors work in a similar way. The major difference is that IDs can only be applied once per page, while classes can be used as many times on a page as needed.
2nd Aug 2017, 4:31 PM
Calviղ
Calviղ - avatar
0
classes are blocks of 'code' (style) that you can add later to an element by adding the attribute class="myClass" ids are the same, but, ids are meant to be unique, you can of course have many elements with the sane id and therefore the sane style, but that will interfere with any script on the page example: <p id="unique">Yep</p> <p>nope</p> #unique { color: red; } only the #unique p is gonna be red
2nd Aug 2017, 4:32 PM
voidneo