DEV Community

Discussion on: What Are :before and :after Pseudo Elements?

Collapse
 
maxart2501 profile image
Massimo Artizzu • Edited

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!

h2::before {
  content: "";
  border-style: solid;
  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.

Collapse
 
patrickcole profile image
Patrick Cole

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!

Collapse
 
neshaz profile image
Nesha Zoric

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! :)