#id vs Inline CSS | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

#id vs Inline CSS

Say I have an element, an h3, in a div with a paragraph and some other elements. Now lets say that both the tags for the entire html document and the class for this div have all been styled in an external css document but I want to style just this one unique occurence of this specific h3. Is it better to give the h3 element an id and add it to the external css code or simply add some inline css? It seems inefficient to create an id for a single, one off styling.

22nd May 2019, 4:24 PM
Domingo Gonzales III
2 Réponses
+ 5
I think it depends on your preference. I would go for inline as it will be fast to apply!
22nd May 2019, 4:45 PM
Kartik
Kartik - avatar
+ 3
It would be better to use the id. Because than css and html is better organized.
22nd May 2019, 4:29 PM
Dragonxiv
Dragonxiv - avatar