What’s the deal with :: in CSS?

Have you ever wondered why some CSS rules have single colon (:) and others have a double (::)?

If we put aside browser support there really is no difference between using single or double colons. BUt if we loook a little deeper the single colon syntax (e.g. “:before” or “:first-child”) is the syntax used for both pseudo-classes and pseudo-selectors in all versions of CSS prior to CSS3. With the introduction of CSS3, in order to make a differentiation between pseudo-classes and pseudo-elements (yes, they’re different), in CSS3 all pseudo-elements must use the double-colon syntax, and all pseudo-classes must use the single-colon syntax.

Leave a Reply

Your email address will not be published.