SomeoneMysterious
SomeoneMysterious

Reputation: 45

Is it possible to include the pseudo element inside it's parent element css

I would like to format my css such that each relevant element is within their own class, including the class's pseudo-elements. Currently, the pseudo-element is formatted this way.

element {
   ...
}

element::after {
   ...
}

Is it possible to format the above into this format? Basically nesting the pseudo-element inside it's parent element.

element {
   ...
   element::after {
      ...
   }
}

Upvotes: 0

Views: 285

Answers (1)

LSE
LSE

Reputation: 1358

Not with vanilla css.
You have a few options, such as Scss, Less, Stylus and Postcss(with a plugin).

If you're just starting, I'd recommend Scss:

.element {
  &::after {
  }
}

Upvotes: 1

Related Questions