What is the difference between ::before and :before ? Or ::after and :after ?

    2 answers 2

    Previously, with the advent of CSS2.1 syntax of pseudo-elements (for example :before ) and pseudo-classes (for example :first-child ) did not differ: both versions were written with a colon as a prefix to indicate their pseudo-essence.

    With the advent of CSS3 comrades from the W3C decided to point out how they differ from each other, leaving one colon for the pseudo-classes ( :not ), but entering a double colon for the pseudo-elements ( ::before and ::after ).

    PS Everyone's favorite IE to version 9.0 does not support double colons, so it’s safer to use still single ones, if the development is not only for modern browsers.

    In more detail about pseudo-elements it is possible to read according to the link: pseudo-element :: before

      :before , like :after left to support older browsers. There is no difference .

      / * CSS3 syntax * /

      element::before { свойства }

      / * CSS2 outdated syntax (only needed for IE8 support) * /

      element:before { свойства }

      * Source

      • 2
        :before , like :after were not added to support old browsers, just the opposite, new browsers support pseudo-elements with a double colon, and the single colon was originally. - lexxl
      • @lexxl essentially does not change. - smellyshovel