Guidlines for choosing class / ID name? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Guidlines for choosing class / ID name?

Is there any recommendations for choosing the class / ID "name"?

2nd Mar 2017, 7:54 AM
Caway
Caway - avatar
2 Answers
+ 7
(An add-on to what @Rain said) @Caway: Use semantic class and id names so that it improves code readability and helps in cases where you are a part of a web developer team working on the same CSS file. Even if you use in your personal projects, it helps you to co-relate your css with html elements much more easily and quickly Ex: 'nav' class/id name for the navigation bar; 'footer' class/id name for a footer;
2nd Mar 2017, 8:36 AM
Chirag Bhansali
Chirag Bhansali - avatar
+ 2
Well thing about your class and what it is trying to do. If you are making a class with properties of a brick, call that class brick. If your class is derived from brick, and is a fire brick, name the bricj fire, and then derive from brick. Make your class names relatively simple, so that while you are working on big projects, you won't have to think about what you named that one class.
2nd Mar 2017, 8:06 AM
Rain
Rain - avatar