Unless you're targeting IE8 without Autoprefixer or similar processor, please use the syntax with two colons: ::before and ::after.
The single colon syntax is for pseudo classes, while the double colon is for pseudo elements.
Anyway, another nice use? Triangles!
border-width: 10px 10px 10px 0;
border-color: transparent currentcolor;
Triangles are just some basic shape, you can actually have some fun with them. And it's still a legit use as they're still decorations.
Thanks for pointing this out Massimo! I guess I had not picked up on the fact that the double colon was the updated spec for pseudo elements. Definitely helped me understand the difference between the pseudo elements and pseudo classes!
Hey, Massimo! Yes, I agree, triangles are very interesting. This article was focused on the basic usage of :before and :after element, but triangles are indeed a great example. Thanks! :)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.