0

I have seen some examples like this

p.class1 { some stuff }
p.class2 {some stuff }

and some like this

class1.p {stuff}
class2.p {stuff}

In one case, the class name is before the dot, in the other case the class name is after the dot. What is the difference between these two notations?

Thanks,
Dave

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by daviddoria
0

It's the nesting order of the elements. For instance:

p .red { color:red }

would apply a style to elements nested in p tags with the class="red" like below:

<p>The following span is <span class="red">red</span></p>

It would display as: The following span is red
Also,

.class1 p {color:green}

would apply a style to p elements nested under elements with class="class1" like below:

<div class="class1">Bill had <p>green</p> shoes on.</div>

It would display as:
Bill had
green
shoes on.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.