6

In CSS, there are pseudo elements like "before" and "after". That creates virtual elements before or after an element.

Container pseudo element?

Is there a "container" pseudo element?

Problem example 1:

I need to create 15 borders around an element (I know this particular example can be done by using box-shadow).

Problem example 2:

I need to create 15 transparent background colors on top of eachother.

A lot of unnecessary markup

I know that is possible by adding containing divs, but that creates a lot of unnecessary markup.

5
  • 2
    Is there a question in there? Commented Jul 20, 2012 at 20:00
  • 1
    ::before and ::after are pseudo-elements, not pseudo-classes; and what do you mean by 'container' pseudo-class (I assume you mean pseudo-element, as with the other two)? Commented Jul 20, 2012 at 20:01
  • How exactly would a container pseudo class work? Commented Jul 20, 2012 at 20:01
  • See this answer stackoverflow.com/a/4574946/886539 Commented Jul 20, 2012 at 20:02
  • ::before and ::after create virtual elements before and after the content of an element, not the element itself - stackoverflow.com/questions/5362811/… Commented Jul 20, 2012 at 20:22

1 Answer 1

9

The old CSS3 Generated and Replaced Content Module had a proposal for an ::outside pseudo-element which seems close to what you describe, but there are no implementations, and the module itself is slated for a rewrite... someday.

In other words, there's currently no way to achieve this using only CSS, and there probably won't be any for a while.

Of course, there are ways to emulate wrapping elements using JavaScript to manipulate the DOM, but that's just about the only way you can achieve this besides hardcoding in the extra markup. Some trivial jQuery methods with respect to the fabled ::outside pseudo-element are described here:

Enable support for CSS3 ::outside pseudoelement

Sign up to request clarification or add additional context in comments.

1 Comment

And no one browser want to implement full support after 9 years. Author of this module = author of ACID tests.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.