As mentioned in the comments, Firefox is dropping the rule because the .sub-menu:after li
in your selector is invalid. In CSS2.1 and Selectors 3, only one pseudo-element may appear at most per complex selector and it must be at the very end of the selector. When encountering an invalid selector in a ruleset a browser must drop the entire ruleset. This is why it's not showing up in the inspector.
To fix it, either remove the offending selector, as it appears to be a mistake:
.clearfix:after,
.sub-menu:after {
content: "";
display: table;
clear: both;
}
Or if you meant to apply the :after
pseudo-element to .sub-menu li
, relocate the pseudo-element like so:
.clearfix:after,
.sub-menu:after,
.sub-menu li:after {
content: "";
display: table;
clear: both;
}
So, instead of asking why this CSS doesn't work on Firefox, the real question is: why does Chrome accept it? That's most likely because WebKit (and by extension Blink) is known to be more lenient when it comes to parsing pseudo-elements, perhaps due to the fact that it employs certain non-standard features that require actively violating the spec. To quote this other answer of mine:
Perhaps the root of the problem lies in the very fact that you're trying to add generated content to other pseudo-elements, which again seems to work in WebKit browsers for whatever bizarre reason. Unlike the above issue with generated content within replaced elements, the current Selectors 3 spec and the upcoming Selectors 4 spec are both very clear on this: you are not supposed to have more than one pseudo-element per complex selector. Of course, WebKit has infamously flouted various rules when it comes to implementing pseudo-elements, so in hindsight it does not surprise me to see WebKit mess up doing so.
Either way, the real conclusion is that the implementation of CSS generated content is extremely poor beyond the scope of the current standard of CSS2.1 + Selectors, by which I mean generated content for replaced elements such as input
and progress
, and nesting of pseudo-elements in a single selector.