HTML TO CSS LINKING ELEMENTS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HTML TO CSS LINKING ELEMENTS

So let's say we have an HTML file and a CSS file they are linked, so now I want to start working on the css code, so I know we have in line elements and block elements my question is how do I know whether to give the element a <id=""> or a <class=""> attribute?

3rd Jun 2019, 8:59 PM
Michael Moore
Michael Moore - avatar
3 Answers
+ 1
If you know for certain, that you'll only have 1 element of that type, use id, otherwise use class
3rd Jun 2019, 9:03 PM
Airree
Airree - avatar
0
Right on!
3rd Jun 2019, 9:04 PM
Michael Moore
Michael Moore - avatar
0
Ist of all id and class are not html tags they are attribute, add a id or class in your element like this <p class="text" id="main"></p> You can put same class for two elements, but id should be unique for each element
4th Jun 2019, 4:20 AM
Bug Slayer