+ 1
h1.class vs .class h1
Are they essentially the same thing? Why should I use one vs the other? Any help would be greatly appreciated! :)
3 Réponses
+ 1
If you're talking about the css selector
h1.class means the all elements h1 that have the class called "class" (in this case)
.class h1 means, all h1 elements inside elements that contain the class "class"
You can stack elements to select meticulously, for example:
section#main:nth-child(7) span.highlight
the line above looks for a span that contains the class highlight, which is inside the seventh element inside the section whose id is "main".
But instead you should use just span.highlight unless you have many, and want to select only one, or a selected few
0
in fact there is no difference here, to be honest, you're right! :)
0
h1.class===class.h1