CSS Syntax Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

CSS Syntax Question

Hi all, Looking at the following examples, why is there a period (a dot) after the selector in the second list of examples? List One: h1 { font-size: 2.5em; /* 40px/16=2.5em */ } h2 { font-size: 1.875em; /* 30px/16=1.875em */ } p { font-size: 0.875em; /* 14px/16=0.875em */ } List Two: p.normal { font-variant: normal; } p.small { font-variant: small-caps; } ------------------------------------------------------------------- In essence, why in the second list of examples is there a dot after the paragraph selector? Why is there an indicator as to the font size after the "p." and not inside the { } brackets? If they were classes, I could understand, but they're not. Classes have the period (the dot) before the selector (I.e. .p {...}). Thanks.

20th Jul 2018, 7:25 PM
Mathew McRae
Mathew McRae - avatar
5 Answers
+ 8
the dot comes before the class name and in these cases p.normal {...} p.small {...} "normal" and "small" are classes and this is a more specific selector for a paragraph element (p) with given classes it would be better if you had a HTML code as well my guess it would look something like this: <body> <h1>some text</h1> <h2>some more text</h2> <p>some paragraph text</p> <p class="normal"> some normal paragraph text </p> <p class="small"> some small paragraph text </p> </body>
20th Jul 2018, 7:38 PM
Burey
Burey - avatar
+ 8
not a pseudo class just a regular class these are pseudo classes: https://www.w3schools.com/css/css_pseudo_classes.asp
20th Jul 2018, 8:29 PM
Burey
Burey - avatar
+ 1
Thanks very much for that, Burey. Is that what you'd call a 'pseudo-class'?
20th Jul 2018, 8:02 PM
Mathew McRae
Mathew McRae - avatar
0
Would you call that a pseudo-class, guys?
21st Jul 2018, 4:48 PM
Mathew McRae
Mathew McRae - avatar
0
Ah, I now know that it's not a pseud-class. I'm still not too familiar with pseudo-classes and pseudo-elements and the difference between the two.
21st Jul 2018, 5:19 PM
Mathew McRae
Mathew McRae - avatar