Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
Presentation levels are integer values attached to elements in a document. Elements that are below, at, or above a certain threshold can be styled differently. This feature has two compelling use cases. First, slide presentations with transition effects can be described. For example, list items can be progressively revealed by sliding in from the side. Second, outline views of documents, where only the headings to a certain level are visible, can be generated.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by the CSS Working Group (part of the Style Activity).
The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this document. When sending e-mail, please put the text “css3-preslev” in the subject, preferably like this: “[css3-preslev] …summary of comment…”
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 1 August 2014 W3C Process Document.
At this time, the CSS Working Group does not envisage further work on this specification and does not plan to propose it as a W3C Recommendation.
Content reuse has been one of the main motivations for the development of style sheets. By associating documents with different style sheets, the same content can be presented in different ways. The introduction of presentation levels in CSS adds functionality which is very useful in two particular settings. First, slide presentations with transition effects can be described. For example, list items can be progressively revealed by sliding in from the side. Second, outline views of documents, where only the headings to a certain level are visible, can be generated.
The model behind presentation levels is simple. Each element in the
document is assigned an integer value which is referred to as the
"element's presentation level" (EPL). The EPL can be set explicitly in a
style sheet or calculated automatically based on the element's position in
the document structure: it is specified by the computed value of the ‘presentation-level
’ property. The User Agent
maintains another integer value which is called the User Agent
Presentation Value (UAPL). The UAPL starts at a UA-defined value,
typically 0.
All elements are in one of three presentation pseudo-classes: ‘below-level
’, ‘at-level
’, and ‘above-level
’. These
pseudo-classes refer to whether the element's EPL was below, at, or above
the UAPL the last time the UAPL changed. When an element's state is
evaluated, the EPL is compared to the UAPL and pseudo-classes are assigned
as follows: If the EPL is equal to 0, the element is always in the
below-level state. If the EPL is lower than the UAPL value, it is set to
the ‘below-level
’ state, if the EPL is
exactly that value it is set to ‘at-level
’, and if the EPL is greater than that
value it is set to ‘above-level
’.
Here is an example of a style sheets using the presentation pseudo-classes:
:below-level { color: black } :at-level { color: red } :above-level { color: silver }
This proposal does not describe the user interface of presentation levels. The user agent will need to provide a user interface for setting the UAPL. For example, in projection mode, a user agent may increase the UAPL every time the user hits the space bar. When the user moves to another page (for example by following a hyperlink), the user agent may set the UAPL to be the same as presentation level of the first element on the page. In outline mode, the user agent may provide a vertical slider on the side to increase/decrease the UAPL.
presentation-level
’ propertyName: | presentation-level |
Value: | <integer> | same | increment |
Initial: | 0 |
Applies to: | all elements |
Inherited: | yes |
Percentages: | N/A |
Computed value: | integer |
User Agents are expected to support this property on all media, including non-visual ones.
This property sets the element's presentation level (EPL). The values have the following meanings:
increment
’ computes to a value one more
than the previous (in document order) element's presentation level.same
’ computes to the same value as the
previous element's (in document order) presentation level. For the root
element, ‘same
’ computes to zero.Here is an example of how presentation levels can be used to progressively reveal list items while high-lighting the current one.
EPL value <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> 0 <STYLE> 0 html { color: black; background: white } @media projection { h1 { page-break-before: always } li { presentation-level: increment } :below-level { color: black } :at-level { color: red } :above-level { color: silver } } </STYLE> <BODY> 0 <H1>Strategies</H1> 0 <H2>Our strategy</H2> 0 <UL> 0 <LI>divide 1 <LI>conquer 2 <P>(in that order) 2 </UL> <H2>Their strategy</H2> 0 <UL> 0 <LI>obfuscate 1 <LI>propagate 2 </UL>
In the example above, the LI elements' EPL value is increased with one
compared to the previous element. The other elements' EPL value is the
same as the previous element due to the initial ‘same
’ value of the ‘presentation-level
’ property.
Here is an example of how presentation levels can be used to present outline views of a document:
EPL value <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> 0 <STYLE> h1 { presentation-level: 0; } h2 { presentation-level: 1; } h3 { presentation-level: 2; } body * { presentation-level: 3; } :above-level { display: none; } </STYLE> <BODY> 0 <H1>Strategies</H1> 3 <H2>Our strategy</H2> 2 <UL> 0 <LI>divide 0 <LI>conquer 0 <P>(in that order) 0 </UL> <H2>Their strategy</H2> 2 <UL> 0 <LI>obfuscate 0 <LI>propagate 0 </UL>
An element's state is first evaluated when it is created. When the UAPL
is changed, all elements in the document have their state reevaluated. A
CSSNowBelowLevel event is then sent to all elements that changed to the
‘below-level
’ state, a CSSNowAtLevel
event is then sent to all elements that changed to the ‘at-level
’ state, and a CSSNowAboveLevel event is
then sent to all elements that changed to the ‘above-level
’ state. Changing an element's ‘presentation-level
’ property, e.g. through
the DOM or using a dynamic pseudo-class, does not cause the element's
state to be immediately reevaluated.
These events have the following characteristics:
SMIL can be used with this event to declaratively key animations from
user requests, based on the ‘presentation-index
’ property.
The events are defined as:
interface CSSNowBelowLevel : UIEvent { } interface CSSNowAtLevel : UIEvent { } interface CSSNowAboveLevel : UIEvent { }
These three fragments together will cause a document to have three user-triggered list items, which will scroll in one at a time each time the user hits the space bar (or whatever mechanism the UA uses), with the current item colored white and the past items colored gray.
Markup:
<ol> <li> The Separation of Style and Structure </li> <li> Declarative User Interaction </li> <li> Potential for Animation </li> </ol>
Stylesheet:
ol { overflow: hidden; } li { presentation-level: increment; margin-left: 100%; } li:at-level { color: white; } li:above-level { color: silver; }
Script:
// When the element is shown, scroll it in from the right // by animating the margin-left property from 100% to 0% document.documentElement.addEventListener('CSSNowAtLevel', handler, false); function handler(event) { // animateFloat is a (fictional) library routine which takes // five arguments: // a CSSValue to animate // the start value // the end value // the time over which to animate the property, in milliseconds // the units to animate it with // it returns straight away and performs the animation in the // background. animateFloat(document.getOverrideStyle(event.target, null).getPropertyCSSValue('margin-left'), 100, 0, 1000, CSS_PERCENTAGE); }