Where is the difference? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 7

Where is the difference?

I have this for example: <aside id="sidebar"> </aside> My question is, where is the difference between this: aside#sidebar {} and this: #sidebar {} And if there is a difference, then what's better?

15th Apr 2017, 1:26 AM
Tim G
Tim G - avatar
2 Réponses
+ 8
Both are targeting the same element, but first get more priority ( specificity ) than second... if you write: aside#sidebar { color:red; } #sidebar { color:blue; } ... the color will be red, because first has higher priority and so, is not override by the second rule declaration. https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity https://hungred.com/useful-information/css-priority-order-tips-tricks/
15th Apr 2017, 1:41 AM
visph
visph - avatar
+ 7
@visph, Thanks🙏
15th Apr 2017, 1:43 AM
Tim G
Tim G - avatar