CSS Logical Properties Level 1

Editor’s Draft, 17 July 2014

This version:
http://dev.w3.org/csswg/css-logical-props/
Feedback:
www-style@w3.org with subject line “[css-logical-props] … message topic …”(archives)
Editors:
(Microsoft)
fantasai (Mozilla)

Abstract

This module introduces logical properties and values that provide the author with the ability to control layout through logical, rather than physical, direction and dimension mappings. The module defines logical properties and values for the features defined in [CSS21]. These properties are writing-mode relative equivalents of their corresponding physical properties.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress.

The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-logical-props” in the subject, preferably like this: “[css-logical-props] …summary of comment…

This document was produced by the CSS Working Group (part of the Style Activity).

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.

Table of Contents

1 Logical Directional Values: before, after, start, end

Properties that accept physical directional keyword values (top, bottom, left, or right) are redefined to also accept the appropriate logical directional keywords (before, after, start, or end). In such cases, the logical values can be used in place of the corresponding physical values. For properties that take multiple keywords, combinations of logical and physical values are not allowed.

The following properties accept the start and end keywords where left and right are allowed:

The following properties accept the before and after keywords where

top and bottom are allowed:

See the section on Abstract Layout details on how to map between logical and physical terms. This mapping controls the interpretation of logical keywords.

float needs coordination with GCPM where it defines page floats

resize accepts horizontal and vertical, and these terminologies should be physical. should we add 'resize-x and resize-y' as logical values?

2 Logical Page Classifications

In CSS, all pages are classified by user agents as either left pages or right pages. [CSS21] Which page is first in a spread, however, depends on whether the page progression is left-to-right or right-to-left.

To allow control of page breaking to the page that is on the earlier or later side of a spread, rather than to the left or right side of a spread, this module introduces the following additional keywords for the page-break-after and page-break-before properties [CSS21]:

recto
Equivalent to right in left-to-right page progressions and left in right-to-left page progressions.

verso
Equivalent to left in left-to-right page progressions and right in right-to-left page progressions.

recto/verso or even/odd or even-page/odd-page? If using odd/even, could use "The page number used to determine whether a page is even or odd is the physical page count starting from 1, and is sometimes different from the page number printed on the page. In other words, if a page is on the same side as the first page, it is an odd page." But which side would we want if page-break-before changes the first page?

Logical page selectors are added to support logical page selection. Authors typically place page numbers using physical placements, but the contents of headers often follows conventions depending on which page in the spread is earlier.

Following page selectors are added to support this scenario:

:recto
Equivalent to ':right' in left-to-right page progressions and ':left' in right-to-left page progressions.

:verso
Equivalent to ':left' in left-to-right page progressions and ':right' in right-to-left page progressions.

The logical page selectors have specificity equal to the ':left' and ':right' page selectors.

2.1 Logical Height and Logical Width: the length and measure properties

Name:measure, length
Value:length | percentage | auto
Initial:auto
Applies to:same as width and height
Inherited:no
Media:visual
Computed value:the percentage as specified or the absolute length or auto (see text)
Percentages:measure, length of containing block

These properties correspond to the width and height properties. The mapping depends on the element’s writing-mode.

Name:min-measure, min-length
Value:length | percentage
Initial:0
Applies to:same as width and height
Inherited:no
Media:visual
Computed value:the percentage as specified or the absolute length (see text)
Percentages:measure, length of containing block

These properties correspond to the max-width and max-height properties. The mapping depends on the element’s writing-mode.

Name:max-measure, max-length
Value:length | percentage | none
Initial:none
Applies to:same as width and height
Inherited:no
Media:visual
Computed value:the percentage as specified or the absolute length or none (see text)
Percentages:measure, length of containing block

These properties correspond to the min-width and min-height properties. The mapping depends on the element’s writing-mode.

2.2 Logical Margins and Offsets: : the margin- and offset- before/after/start/end properties

Name:margin-before, margin-after, margin-start, margin-end
Value:length | percentage | auto
Initial:0
Applies to:same as margin
Inherited:no
Media:visual
Computed value:the percentage as specified or the absolute length or auto (see text)
Percentages:logical-width of containing block

These properties correspond to the margin-top, margin-bottom, margin-left, and margin-right properties. The mapping depends on the parent element’s writing-mode, direction, and text-orientation.

Name:offset-before, offset-after, offset-start, offset-end
Value:length | percentage | auto
Initial:auto
Applies to:positioned elements
Inherited:no
Media:visual
Computed value:same as box offsets: top, right, bottom, left properties except that directions are logical
Percentages:logical-width, resp. logical-height of containing block

These properties correspond to the top, bottom, left, and right properties. The mapping depends on the parent element’s writing-mode, direction, and text-orientation.

2.3 Logical Padding and Border: the padding- and border-*- before/after/start/end properties

Name:padding-before, padding-after, padding-start, padding-end
Value:length | percentage
Initial:0
Applies to:all elements
Inherited:no
Media:visual
Computed value:length (see text)
Percentages:logical-width of containing block

These properties correspond to the padding-top, padding-bottom, padding-left, and padding-right properties. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name:border-before-width, border-after-width, border-start-width, border-end-width
Value:border-width
Initial:medium
Applies to:all elements
Inherited:no
Media:visual
Computed value:absolute length; 0 if the border style is none or hidden (see text)
Percentages:logical-width of containing block

These properties correspond to the border-top-width, border-bottom-width, border-left-width, and border-right-width properties. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name:border-before-style, border-after-style, border-start-style, border-end-style
Value:border-style
Initial:none
Applies to:all elements
Inherited:no
Media:visual
Computed value:specified value (see text)
Percentages:n/a

These properties correspond to the border-top-style, border-bottom-style, border-left-style, and border-right-style properties. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name:border-before-color, border-after-color, border-start-color, border-end-color
Value:color
Initial:currentcolor
Applies to:all elements
Inherited:no
Media:visual
Computed value:computed color (see text)
Percentages:n/a

These properties correspond to the border-top-color, border-bottom-color, border-left-color, and border-right-color properties. The mapping depends on the element’s writing-mode, direction, and text-orientation.

Name:border-before, border-after, border-start, border-end
Value:border-width || border-style || color
Initial:(see individual properties)
Applies to:all elements
Inherited:no
Media:visual
Computed value:see individual properties
Percentages:see individual properties

These properties correspond to the border-top, border-bottom, border-left, and border-right properties. The mapping depends on the element’s writing-mode, direction, and text-orientation.

2.4 Shorthand Properties with logical Keyword

The shorthand properties for margin, padding, and border set values for physical properties by default. But authors can specify the logical keyword at the beginning of the property value to indicate that the values map to the logical properties instead of the physical ones.

other candidates of the keyword are: relative, script, writing-mode, beas, or the value itself (e.g., vertical-lr-ltr)

The following [CSS21] shorthand properties accept the logical keyword:

The syntax for these properties is effectively changed by replacing

<value-type>{1,4}

with

logical? <value-type>{1,4}

When the logical keyword is present in the value, the values that follow are assigned to the logical properties as follows:

Should the shorthand also reset the physical properties to their initial values?

In the following example, the two rules are equivalent:

blockquote {
  margin: logical 1em 2em 3em 4em;
}
blockquote {
  margin-before: 1em;
  margin-end:    2em;
  margin-after:  3em;
  margin-start:  4em;
}

3 Logical Background and Border Images

[CSS3BG] is handled separately because it can fill an area with specified images, and the area to fill can be rotated or flipped depending on the text flow.

3.1 Background Image Transform: The background-image-transform property

Name:background-image-transform
Value:logical | physical | rotate
Initial:physical
Applies to:all elements
Inherited:yes
Media:visual
Computed value:as specified
Percentages:n/a

is this the right default? we need to investigate which is more common

This property defines whether background images are transformed to match to the value of writing-mode property, and whether background-size widths and heights are logical or physical. Values have the following meanings:

logical
The values for the background-size property are logical. The background images are transformed to match to the logical axis.

physical
The values for the background-size property are physical. The background images remain unchanged.
rotate
Similar to logical, except that the inline direction is ignored. The result is affected only by the block flow direction.

3.2 The background-repeat property

The repeat-x and repeat-y values are logical, but in CSS3 this property can also accept double values to specify horizontal and vertical behaviors separately. The double values are considered logical if the logical keyword is specified, otherwise physical.

should also add repeat-horizontal and repeat-vertical for the physical value?

3.3 Border Image Transform: The border-image-transform property

Name:border-image-transform
Value:logical | physical | rotate
Initial:rotate
Applies to:All elements, except internal table elements when border-collapse is collapse
Inherited:yes
Media:visual
Computed value:as specified
Percentages:n/a

is this the right initial default?

This property defines whether border images are transformed to match to the value of writing-mode property, with the reference writing mode being writing-mode: horizontal-tb; direction: ltr. Values have the following meanings:

logical
The values for the border-image-* properties are logical. The border images are transformed to match to the logical axis.

physical
The values for the border-image-* properties are physical. The border images remain unchanged.
rotate
Similar to logical, except that the inline direction is ignored. The result is affected only by the block flow direction.

The following properties use the value of this property to determine how directional mappings are done:

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words "for example" or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word "Note" and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Experimental implementations

To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.

Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

References

Normative References

[CSS21]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. W3C Recommendation. URL: http://www.w3.org/TR/2011/REC-CSS2-20110607
[CSS3BG]
Bert Bos; Elika J. Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. 24 July 2012. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2012/CR-css3-background-20120724/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. URL: http://www.ietf.org/rfc/rfc2119.txt

Informative References

Index

Property index

NameValueInitialApplies toInh.%agesMediaComputed value
measurelength | percentage | autoautosame as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
lengthlength | percentage | autoautosame as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
min-measurelength | percentage0same as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length (see text)
min-lengthlength | percentage0same as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length (see text)
max-measurelength | percentage | nonenonesame as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length or none (see text)
max-lengthlength | percentage | nonenonesame as width and heightnomeasure, length of containing blockvisualthe percentage as specified or the absolute length or none (see text)
margin-beforelength | percentage | auto0same as marginnological-width of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
margin-afterlength | percentage | auto0same as marginnological-width of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
margin-startlength | percentage | auto0same as marginnological-width of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
margin-endlength | percentage | auto0same as marginnological-width of containing blockvisualthe percentage as specified or the absolute length or auto (see text)
offset-beforelength | percentage | autoautopositioned elementsnological-width, resp. logical-height of containing blockvisualsame as box offsets: top, right, bottom, left properties except that directions are logical
offset-afterlength | percentage | autoautopositioned elementsnological-width, resp. logical-height of containing blockvisualsame as box offsets: top, right, bottom, left properties except that directions are logical
offset-startlength | percentage | autoautopositioned elementsnological-width, resp. logical-height of containing blockvisualsame as box offsets: top, right, bottom, left properties except that directions are logical
offset-endlength | percentage | autoautopositioned elementsnological-width, resp. logical-height of containing blockvisualsame as box offsets: top, right, bottom, left properties except that directions are logical
padding-beforelength | percentage0all elementsnological-width of containing blockvisuallength (see text)
padding-afterlength | percentage0all elementsnological-width of containing blockvisuallength (see text)
padding-startlength | percentage0all elementsnological-width of containing blockvisuallength (see text)
padding-endlength | percentage0all elementsnological-width of containing blockvisuallength (see text)
border-before-widthborder-widthmediumall elementsnological-width of containing blockvisualabsolute length; 0 if the border style is none or hidden (see text)
border-after-widthborder-widthmediumall elementsnological-width of containing blockvisualabsolute length; 0 if the border style is none or hidden (see text)
border-start-widthborder-widthmediumall elementsnological-width of containing blockvisualabsolute length; 0 if the border style is none or hidden (see text)
border-end-widthborder-widthmediumall elementsnological-width of containing blockvisualabsolute length; 0 if the border style is none or hidden (see text)
border-before-styleborder-stylenoneall elementsnon/avisualspecified value (see text)
border-after-styleborder-stylenoneall elementsnon/avisualspecified value (see text)
border-start-styleborder-stylenoneall elementsnon/avisualspecified value (see text)
border-end-styleborder-stylenoneall elementsnon/avisualspecified value (see text)
border-before-colorcolorcurrentcolorall elementsnon/avisualcomputed color (see text)
border-after-colorcolorcurrentcolorall elementsnon/avisualcomputed color (see text)
border-start-colorcolorcurrentcolorall elementsnon/avisualcomputed color (see text)
border-end-colorcolorcurrentcolorall elementsnon/avisualcomputed color (see text)
border-beforeborder-width || border-style || color(see individual properties)all elementsnosee individual propertiesvisualsee individual properties
border-afterborder-width || border-style || color(see individual properties)all elementsnosee individual propertiesvisualsee individual properties
border-startborder-width || border-style || color(see individual properties)all elementsnosee individual propertiesvisualsee individual properties
border-endborder-width || border-style || color(see individual properties)all elementsnosee individual propertiesvisualsee individual properties
background-image-transformlogical | physical | rotatephysicalall elementsyesn/avisualas specified
border-image-transformlogical | physical | rotaterotateAll elements, except internal table elements when border-collapse is collapseyesn/avisualas specified

Issues Index

float needs coordination with GCPM where it defines page floats
resize accepts horizontal and vertical, and these terminologies should be physical. should we add 'resize-x and resize-y' as logical values?
recto/verso or even/odd or even-page/odd-page? If using odd/even, could use "The page number used to determine whether a page is even or odd is the physical page count starting from 1, and is sometimes different from the page number printed on the page. In other words, if a page is on the same side as the first page, it is an odd page." But which side would we want if page-break-before changes the first page?
other candidates of the keyword are: relative, script, writing-mode, beas, or the value itself (e.g., vertical-lr-ltr)
Should the shorthand also reset the physical properties to their initial values?
is this the right default? we need to investigate which is more common
should also add repeat-horizontal and repeat-vertical for the physical value?
is this the right initial default?