My main goal is to try to reorder a CSS style block based on specificity. I previously had helped from SO and I managed to produce this function. See gist.
Here is an e
The problem should go away if you serialize
html, body, body div{
background: transparent;
}
as separate rules, as if they were written in the following manner:
html{
background: transparent;
}
body{
background: transparent;
}
body div{
background: transparent;
}
The semantics is a bit confusing, but basically you are judging an entire declaration based on independent selectors that have been combined into the same rule set.
Re your update: specificity is not affected by selector order, i.e. the rules below have the same specificity. The last rule will take precedense rendering in blue, unless you re-arrange the rules rendering in red:
Hello world!