This creates two pseudo elements:
.myElement {}
.myElement::before,
.myElement::after {
content: '';
}
How to add more pseudo elements to the element? Is there a way to add a pseudo element to another pseudo element?
This creates two pseudo elements:
.myElement {}
.myElement::before,
.myElement::after {
content: '';
}
How to add more pseudo elements to the element? Is there a way to add a pseudo element to another pseudo element?
No, you can't.
The pseudo elements are defined as (by W3 docs)
12.1 The :before and :after pseudo-elements
As their names indicate, the :before and :after pseudo-elements specify the location of content before and after an element's document tree content.
Since the document tree is the element's defined source code, a pseudo element cannot contain another pseudo element, since it has no tree.
There is a CSS pseudo element '::before(2)' but unfortunately, there isn't any browser support yet for this :
div { content: 'A' }
div::before { content: 'B'; }
div::before(2) { content: 'C'; }
...would result in the following rendering objects:
,-----------------------.
| ,---. ,---. |
| | C | | B | A |
| `---' `---' |
`-----------------------'
Source : http://www.w3.org/TR/css3-content/#inserting0
Browser support : http://realworldvalidator.com/css/pseudoelements/::before%282%29