I am working on a project where i am using an internal UI Library. In one of the CSS file, i saw something which looks strange. To simplify things, I am reciprocating with basic html elements and corresponding css:
CSS:
div{
border:1px solid black;
width:100px;
height:100px;
}
.parent
//some comment exists here
.child{
background-color: red;
}
.anotherdiv{
background-color: blue;
}
and HTML :
<div class='parent same'>Parent
<div class='child'>Child</div>
</div>
<div class='anotherdiv'></div>
When i tried to check above thing on firefox, i got below warning under CSS console.
Dangling combinator: Ruleset ignored due to bad selector
I tried to approach the problem backwards, i.e. for the given CSS:
.parent
//some comment exists here
.child{
background-color:red;
}
I thought above will resolve either to
.parent .child{
background-color:red; //applied on inside level element
}
or,
.parent.child{
background-color:red; //applied on same element
}
But either of them is not applied.
And, ruleset defined for div with class anotherdiv
is working perfectly fine.
I want to know how browser reads CSS, and upon reaching some crooked line, how it resolves and how following rulesets in the CSS gets effected.
UPDATE
I cross checked the type of file and it came out as .SCSS
and below is what i found strange
.accordion-toggle
// Inner needs the styles because you can't animate properly with any styles on the element
.accordion-inner {
padding: 9px 15px;
border-top: 1px solid #e5e5e5;
}
Sorry for the previous misunderstanding!