The task was to set red color to all paragraphs in the class standart
I did it this way
.standart p { color:red; }
but I was told it's bad solution and this is the "good one"
p.standart { color:red; }
What's the difference between these two?
The task was to set red color to all paragraphs in the class standart
I did it this way
.standart p { color:red; }
but I was told it's bad solution and this is the "good one"
p.standart { color:red; }
What's the difference between these two?
.standart p { color:red; }
p.standart { color:red; }
<div class="standart">
<p>One</p>
<p>Two</p>
<p>Three</p>
</div>
<hr/>
<p class="standart">One 1</p>
<p class="standart">Two 2</p>
<p class="standart">Three 3</p>
.standart p { color:red; } means you want red color text for all paragraphs inside standart class.
p.standart { color:red; } means you want red color text for all paragraphs having standart class.
It depends. The first one matches each <p> element descendant of an element with the standard class (for example: <div class="standard"><p> ), whereas the second one matches all <p> elements with class standard ( <p class='standard'> ). None of them is incorrect, depends on what you need.
The difference is below
.standart p { color:red; } - it applies on all paragraph text inside the standard class.
p.standart { color:red; } - it applies on all paragraphs text which having the standard class.