This module contains CSS features for aligning content to a baseline grid. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.
The following features are at risk: …
This section is not normative.
This specification provides features to align lines and blocks to invisible grids in the document.
Aligning lines and blocks to grids provides the following benefits:
There are several types of objects in a document that can break the vertical rhythm. Examples include lines with different sizes of text, pictures, and tables.
Vertical rhythm kept through pictures and different size of text in a multi-column document.
Large text wraps within line grids.
When a different size of text, such as a headings, wraps, it is usually aligned to grids as a block and the lines within the block do not align.
Sidenotes are set at a smaller size, but still line up with the basic text.
East Asian layouts may require width be a multiple of em without fractions.
East Asian layouts may require grid-like features in inline progression direction as well.
It is often desirable in East Asian layouts to make the line width a multiple of em without fractions. Because most East Asian characters have 1em advance and most East Asian documents are justified, this minimizes cases where justification needs to expand character spacing.
This module provides the following capabilities:
It is important to control these capabilities independently, so that, for example, aligning to grids can be turned off for tables, but can then be turned back on for aligning the following text to the grids.
This module extends the line box model defined in [[!CSS21]] sections 9.4.2 and 10.8.
This specification follows the CSS property definition conventions from [[!CSS21]]. Value types not defined in this specification are defined in CSS Level 2 Revision 1 [[!CSS21]]. Other CSS modules may expand the definitions of these value types: for example [[CSS3COLOR]], when combined with this module, expands the definition of the <color> value type as used in this specification.
In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the inherit keyword as their property value. For readability it has not been repeated explicitly.
| Name: | line-grid |
|---|---|
| Value: | match-parent | create |
| Initial: | match-parent |
| Applies to: | block containers |
| Inherited: | no |
| Animatable: | no |
| Percentages: | N/A |
| Media: | visual |
| Computed value: | specified value |
| Canonical order: | per grammar |
Specifies whether this box creates a new baseline grid for its descendants or uses the same baseline grid as its parent. (Each box always has an associated line grid. However, whether a box or its contents snap to a line grid is determined by ''line-snap'' and ''box-snap''.)
The names of these values is currently up for debate. Current suggestions for ''match-parent'' include ''match-parent'' and ''normal''; those for ''create'' include ''create'' and ''new''.
The original proposal for line grids allowed an element to create a named grid. This property could still be extended to do this in the future.
Håkon points out that there might be a need to have line grids aligned to the page box rather than the page content box. The current proposal has no way to switch between the two.
There might need to be an offset for more complicated designs. How to set this offset is problematic: usually it's not a fixed length, but the distance to clear some header content. This could be added to a later level of line-grid.
| Name: | line-snap |
|---|---|
| Value: | none | baseline | contain |
| Initial: | none |
| Applies to: | all elements |
| Inherited: | yes |
| Animatable: | no |
| Percentages: | N/A |
| Media: | visual |
| Computed value: | specified value |
| Canonical order: | per grammar |
This property applies to all the line boxes directly contained by the element, and, when not ''none'', causes each line box to shift downward (possibly by zero) until it snaps to the line grid specified by 'line-grid'. (The unshifted position is the position that would be determined by normal line stacking rules, with consideration of any new controls defined by other modules such as [[CSS3LINE]].) Values have the following meanings:
In some cases lines of equal line height will not align perfectly to a baseline grid: this happens, for example, when fonts (of the same size) with different baseline tables are mixed on a line. For this reason, if shifting the line by the largest difference between the smallest ascent and largest ascent of a single size used on the line would result in a smaller shift, then the contents of the line box are shifted up within the line box so as to allow the line to snap without jumping downward to the next grid line.
This is a rough draft of trying to solve the box-snapping problem.
Some optional box values (margin-box, border-box) could be added to the before and after values to allow snapping various box model edges to the line grid.
An 'auto' value could be useful - one that defaults to center, but snaps to before if it's the first block in a fragment container, and snaps to after if it's the last block in a fragment container.
| Name: | box-snap |
|---|---|
| Value: | none | before | after | center | first-baseline | last-baseline |
| Initial: | none |
| Applies to: | block-level boxes and internal table elements except table cells |
| Inherited: | yes |
| Animatable: | no |
| Percentages: | N/A |
| Media: | visual |
| Computed value: | specified value |
| Canonical order: | per grammar |
Specifies how the block is snapped to the baseline grid. Values have the following meanings:
When snapping to baselines on a line grid, either the text-over or text-under baseline is chosen: whichever one is on the matching side of the central baseline. For example, when snapping the before edge in horizontal writing mode, the over edge is chosen. In some cases the under edge might be used instead for the before edge: for example, when the writing mode of the line grid doesn't match that of the affected element, or when due to the 'text-orientation' settings the under side corresponds to the after edge.
To snap a block-level element to a grid line, the effective margin is increased at that edge. If, however, the box is an empty block that could be collapsed through, then this property has no effect. [[!CSS21]]
When applied to table row group and table row boxes, 'box-snap' only affects the before and after edges, and only if those edges are not at the beginning or end of the table, respectively. To snap a before edge on a table row or row group, the preceding row's height is increased. To snap an after edge on a table row or row group, the affected row's height is increased.
When applied to table column group and table column boxes, 'box-snap' only affects the start and end edges, and only if those edges are not at the start or end of the table, respectively. How the space is redistributed among columns to satisfy snapping constraints is not defined, however:
To satisfy these constraints, some column edges may remain unsnapped.
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.
Conformance to CSS Line Grid Level 1 is defined for three conformance classes:
A style sheet is conformant to CSS Line Grid Level 1 if all of its declarations that use properties defined in this module have values that are valid according to the generic CSS grammar and the individual grammars of each property as given in this module.
A renderer is conformant to CSS Line Grid Level 1 if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the properties defined by CSS Line Grid Level 1 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 CSS Line Grid Level 1 if it writes syntactically correct style sheets, according to the generic CSS grammar and the individual grammars of each property in this module.
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.
To avoid clashes with future CSS features, the CSS specifications reserve a prefixed syntax for proprietary property and value extensions to CSS. The CSS Working Group recommends that experimental implementations of features in CSS Working Drafts also use vendor-prefixed property or value names. This avoids any incompatibilities with future changes in the draft. Once a specification reaches the Candidate Recommendation stage, implementors should implement the non-prefixed syntax for any feature they consider to be correctly implemented according to spec.
For this specification to be advanced to Proposed Recommendation, there must be at least two independent, interoperable implementations of each feature. Each feature may be implemented by a different set of products, there is no requirement that all features be implemented by a single product. For the purposes of this criterion, we define the following terms:
The specification will remain Candidate Recommendation for at least six months.
This module was made possible by the advice and contributions of …