I'm working with css and I have tried to add an element 'before' to my div like an arrow. Is there any way to achieve it? I tried pseudo :before but there are three of them (::before(2), :before and ::before). They make me so confuse, what are differences in between?
Asked
Active
Viewed 1.8k times
11
-
1`::before` is the new implementation of the older `:before` -- it was to distinguish the difference between pseudo-elements (::) and pseudo-classes (:). Having said that, IE 8 only accepts `:before` and not the new syntax, while new browsers accept both, so it's better off using the old syntax if you want better compliance. I have **no** idea what `::before(2)` is, I've never seen it before. – Ming Dec 10 '13 at 02:45
-
It looks like `::before(2)` is for multiple `::before` pseudo-elements: http://www.w3.org/TR/css3-content/#inserting however, no major browser supports it yet: http://realworldvalidator.com/css/pseudoelements/::before(2) so don't use it. – Ming Dec 10 '13 at 02:50
-
Does this answer your question? [Can I have multiple :before pseudo-elements for the same element?](https://stackoverflow.com/questions/11998593/can-i-have-multiple-before-pseudo-elements-for-the-same-element) – Toastrackenigma May 15 '20 at 02:08
1 Answers
23
The CSS spec on content describes all three syntaxes.
:before
-- outdated syntax for pseudo elements. Use if older browser support is needed such as IE8. IE9 supports the new syntax. It also seems like iOS Safari does not support the new syntax::before
-- new pseudo element syntax. This is equivalent to::before(1)
::before(n)
-- used to create multiplebefore
elements that can be before other::before
s. Details are in the same spec.- As far as I can tell, no browser supports this.

James Hill
- 60,353
- 20
- 145
- 161

Explosion Pills
- 188,624
- 52
- 326
- 405
-
3
-
11@EveryScreamer We're in the future. The answer is no. (The question was posted some six years ago, and since then, all references to it have disappeared from the draft spec//_ – Jasper Oct 31 '19 at 16:00
-
2
-
1