This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ideas:pseudo-elements [2012/01/12 08:21] – Removed the lone-<dt> pseudo in #3, since that doesn't define a valid item in HTML. tabatkins | ideas:pseudo-elements [2017/01/27 12:16] (current) – bkemper | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Additional Pseudo-Elements ====== | ====== Additional Pseudo-Elements ====== | ||
+ | The ::outside pseudo-element was cut from css3-content and has not been tracked since. Other pseudo-elements concepts like wrapping a range of elements have been discussed from time to time. Additional pseudo-elements with more control over where they are positioned in the tree could help reduce markup clutter where elements are added to HTML for the sole purpose of CSS styling ([[http:// | ||
- | The :: | + | One issue is that there is very little scripting access to pseudo-elements currently. If we end up relying on pseudo-elements |
+ | |||
+ | Another issue is how to provide a way to override pseudo-element styling. If one stylesheet defines a pseudo-element wrapper with some styling, how can a second stylesheet import the first and override the wrapper' | ||
Here is a list of possible pseudo-element additions that could be made in a future spec. | Here is a list of possible pseudo-element additions that could be made in a future spec. | ||
Line 8: | Line 11: | ||
=== 1. Simple wrapping of a single element === | === 1. Simple wrapping of a single element === | ||
- | ::outside was meant to create a pseudo element containing a single element | + | In CSS3 Content, '' |
- | + | <code css> | |
- | <!-- pseudo-element --> | + | div:: |
- | < | + | </ |
- | <!--end --> | + | <code html> |
+ | <!-- pseudo-element --> | ||
+ | < | ||
+ | <!--end --> | ||
+ | </code> | ||
=== 2. Complex wrapping of an element range === | === 2. Complex wrapping of an element range === | ||
A wrapper that contains a range of elements specified by indices. This could be specified as a child interval on a parent, or directly from an element with a number of siblings to contain. | A wrapper that contains a range of elements specified by indices. This could be specified as a child interval on a parent, or directly from an element with a number of siblings to contain. | ||
+ | <code css> | ||
+ | # | ||
+ | </ | ||
+ | <code css> | ||
+ | # | ||
+ | </ | ||
+ | <code html> | ||
+ | <div id=parent> | ||
+ | < | ||
+ | <!-- pseudo-element containing the next three elements --> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <!--end --> | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
- | <div id=parent> | + | If the second idea (starting from the first element to be wrapped, and specifying how many elements to include in the wrapping) is adopted, it could be used to solve #1 as well, by allowing an appropriate default value to wrap only the single element. |
- | <div>1</ | + | |
- | <!-- pseudo-element containing | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <!--end --> | + | |
- | < | + | |
- | </div> | + | |
=== 3. Complex wrapping of selector range === | === 3. Complex wrapping of selector range === | ||
- | A wrapper that contains a range of elements specified by selectors. In this case the declared range is from every <dt> element until the next <dt> following a < | + | A wrapper that contains a range of elements specified by selectors. In this case the declared range is from every <dt> element until the next <dt> following a <dd>. |
- | + | <code css> | |
- | < | + | dl:: |
- | <!-- pseudo-element --> | + | </ |
- | <dt> Last modified time </ | + | <code html> |
- | <dd> 2004-12-23T23: | + | < |
- | <!-- end --> | + | <!-- pseudo-element |
- | <!-- pseudo-element --> | + | <dt> Last modified time </ |
- | <dt> Recommended update interval </ | + | <dd> 2004-12-23T23: |
- | <dd> 60s </ | + | <!-- end </ |
- | <!-- end --> | + | <!-- pseudo-element |
- | <!-- pseudo-element --> | + | <dt> Recommended update interval </ |
- | <dt> Editors </ | + | <dd> 60s </ |
- | <dd> Robert Rothman </ | + | <!-- end </ |
- | <dd> Daniel Jackson </ | + | <!-- pseudo-element |
- | <!-- end --> | + | <dt> Editors </ |
- | </dl> | + | <dd> Robert Rothman </ |
+ | <dd> Daniel Jackson </ | ||
+ | <!-- end </ | ||
+ | </dl> | ||
+ | </code> | ||
=== 4. Sibling pseudo-elements === | === 4. Sibling pseudo-elements === | ||
- | A pseudo-element as a previous or next sibling to an element. In the case below you should be able to place this pseudo-element as following <h1> or previous to <p> | + | A pseudo-element as a previous or next sibling to an element. In the case below you should be able to place this pseudo-element as following <h1> or previous to <p>. |
+ | <code css> | ||
+ | h1::next {border: thick solid green;} | ||
+ | </ | ||
+ | <code css> | ||
+ | p::prev {border: thick solid green;} | ||
+ | </ | ||
+ | <code html> | ||
+ | < | ||
+ | <!-- pseudo-element --> | ||
+ | < | ||
+ | </code> | ||
- | < | ||
- | <!-- pseudo-element --> | ||
- | < | ||
- | | ||
=== 5. Proliferation === | === 5. Proliferation === | ||
- | Mechanisms for adding more than one pseudo-element in some or all of the existing pseudo-element schemes | + | Mechanisms for adding more than one pseudo-element in some or all of the existing pseudo-element schemes. CSS3 Content previously had the ability to specify multiples of a pseudo by specifying an index in square brackets. |
+ | <code css> | ||
+ | div:: | ||
+ | div:: | ||
+ | </ | ||
+ | <code html> | ||
+ | < | ||
+ | <!-- ::before pseudo-element 1 --> | ||
+ | <!-- ::before pseudo-element 2 --> | ||
+ | markup content | ||
+ | </ | ||
+ | </ | ||
- | | + | <code css> |
- | <!-- ::before pseudo-element | + | div::before {border: thick solid green; content=" |
- | <!-- ::before pseudo-element | + | div:: |
- | | + | div::after {border: thick solid green; content=" |
- | </div> | + | div:: |
- | + | </code> | |
- | < | + | <code html> |
- | <!-- nesting ::outside | + | < |
- | | + | |
+ | < | ||
+ | text2 | ||
+ | | ||
+ | text1 | ||
+ | <!-- end --> | ||
+ | | ||
+ | <!-- ::after pseudo-element --> | ||
+ | text3 | ||
+ | <!-- nesting ::after pseudo-element --> | ||
+ | | ||
<!-- end --> | <!-- end --> | ||
<!-- end --> | <!-- end --> | ||
- | | + | </ |
- | < | + | </ |
- | <!-- multiple sibling pseudo-elements --> | + | |
- | <!-- multiple sibling pseudo-elements --> | + | <code css> |
- | <!-- multiple sibling pseudo-elements --> | + | div:: |
- | < | + | div:: |
- | + | </ | |
+ | <code html> | ||
+ | <!-- nesting ::outside pseudo-element --> | ||
+ | <!-- nesting ::outside pseudo-element --> | ||
+ | < | ||
+ | <!-- end --> | ||
+ | <!-- end --> | ||
+ | </ | ||
+ | |||
+ | <code css> | ||
+ | h1::next[1] {border: thick solid green;} | ||
+ | h1::next[2] {border: thick solid lime;} | ||
+ | h1::next[3] {border: thick solid olive;} | ||
+ | </ | ||
+ | <code html> | ||
+ | < | ||
+ | <!-- multiple sibling pseudo-elements --> | ||
+ | <!-- multiple sibling pseudo-elements --> | ||
+ | <!-- multiple sibling pseudo-elements --> | ||
+ | < | ||
+ | </ | ||
=== 6. Complex wrapping of ranges of similar elements === | === 6. Complex wrapping of ranges of similar elements === | ||
- | A wrapper that contains contiguous elements that share a selectable characteristic. In this case, instead of making three simple wrappers around each instance of class bar, it would group the first two bar elements together in one wrapper. | + | A wrapper that contains contiguous elements that share a selectable characteristic. In this case, instead of making three simple wrappers around each instance of class '' |
- | + | <code css> | |
- | <div class=foo></ | + | :: |
- | <!-- pseudo-element that wraps class bar --> | + | </ |
- | <div class=bar></ | + | <code html> |
- | <div class=bar></ | + | <div class=foo></ |
- | <!-- end --> | + | <!-- pseudo-element that wraps class bar --> |
- | <div class=foo></ | + | <div class=bar></ |
- | <!-- pseudo-element that wraps class bar --> | + | <div class=bar></ |
- | <div class=bar></ | + | <!-- end --> |
- | <!-- end --> | + | <div class=foo></ |
- | + | <!-- pseudo-element that wraps class bar --> | |
+ | <div class=bar></ | ||
+ | <!-- end --> | ||
+ | </ | ||
+ | This could potentially also be addressed with #3. | ||
+ | <code css> | ||
+ | :: | ||
+ | </ |