This selector isn’t working like I might expect:
<style type="text/css">
.someClass p, b {
color:red;
cursor : pointer;
}
</style>
<p>This is a test</p>
<p>This is another <b>test</b></p>
<p class="someClass">This is a test with someClass</p>
<p>This is another <b class="someClass">test</b></p>
Results and jsFiddle:
Text for the non-styled paragraphs and styles appear black.
Text for the p with class “someClass” is not appearing with red text, however the b with class “someClass” does appear red.
Problem:
Why does the p class=”someClass” (third paragraph) not appear in red, while the b class=”someClass” (fourth paragraph) appears in red?
Both tags are included in the someClass selector. I’ve not had much luck in finding an answer with searching, and the documentation doesn’t appear to address this exact scenario
If you want your style to apply to paragraphs and
belements with classsomeClass, useYour existing selector targets
belementsomeClass.This code :
is the same as