CSS selectors with an empty declaration - will the browser search again?

Suppose that there are no selectors in the stylesheet that do not have any style information in them, so they are actually empty (do not have style declarations):

.main-menu {} 

Will the browser search for them?

I feel that this will depend on the browser, so a smart programmer would say β€œif the selector remote doesn't bother”, but not all browsers will have such an enlightened implementation. Had a quick search and couldn't find anything, wondered if anyone knew about this in this regard ...

Best practice, I'm sure you don't have selectors with empty declarations, since they are a waste of space and time, does W3 say something about this?

Thanks!

0
performance html css
source share
1 answer

In fact, if the empty CSS rules can really serve to work with some errors in some browsers , it causes errors in others . Thus, there is reason to believe that, for at least two independent implementations, the parser does not ignore CSS rules with empty declaration blocks.

What about best practice? Leave them as they usually do, use extra bytes, and if you have a good reason to use them, you should not add a comment explaining their purpose.

+2
source share

All Articles