h1.class vs .class h1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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! :)

17th Dec 2017, 4:54 PM
Anna
3 Answers
+ 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
17th Dec 2017, 5:49 PM
voidneo
0
in fact there is no difference here, to be honest, you're right! :)
17th Dec 2017, 5:07 PM
James16
James16 - avatar
0
h1.class===class.h1
17th Dec 2017, 5:33 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar