Copyright ©2002 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This document presents a set of CSS line formatting properties. It also includes baseline alignment features as well as related functions like initial line and initial letter effect. It extends on the CSS 2 model [CSS2].
This document is a working draft of the CSS working group which is part of the Style activity (see summary). It contains a proposal for features to be included in CSS level 3.
Feedback is very much welcome. Comments can be sent directly to the editor, but the mailing list www-style@w3.org (see instructions) is also open and is preferred for discussion of this and other drafts in the Style area.
This working draft may be updated, replaced or rendered obsolete by other W3C documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". Its publication does not imply endorsement by the W3C membership or the CSS Working Group (members only).
To find the latest version of this working draft, please follow the "Latest version" link above, or visit the list of W3C Technical Reports.
This CSS3 module depends on the following other CSS3 modules:
It has non-normative (informative) references to the following other CSS3 modules:
This modules specifies the presentation aspects of line within block elements and inline elements. It also covers the design of baseline alignment within each line and the placement of drop initial letter (also known as first letter or drop caps). Most of the properties are new to CSS3.
All described properties, in addition to the noted values, take 'initial' and 'inherit'. These values are not repeated in each of the property value enumeration.
This module uses extensively the 'before', 'after', 'start' and 'end' notation to specify the four edges of a box relative to its text advance direction, independently of its absolute positioning in terms of 'top', 'bottom', 'left' and 'right' (corresponding respectively to the 'before', 'after', 'start' and 'end' positions in a typical Western text layout). This notation is also used extensively in [XSL1.0] for the same purpose.
Finally, in this document, requirements are expressed using the key words "MUST", "MUST NOT", "REQUIRED", "SHALL" and "SHALL NOT". Recommendations are expressed using the key words "SHOULD", "SHOULD NOT" and "RECOMMENDED". "MAY" and "OPTIONAL" are used to indicate optional features or behavior. These keywords are used in accordance with [RFC2119]. For legibility these keywords are used in lowercase form.
This section describes inline boxes formatting, how lines are stacked together and a mechanism to adjust the content height of inline elements.
In an inline formatting context, boxes are laid out in the inline progression direction, one after the other, following the block progression within the containing block. Borders, padding and inline progression margins are respected between these boxes. The boxes may be aligned within the inline progression in different ways: their after-edges or before-edges may be aligned, or the baselines of text within them may be aligned. The rectangular area that contains the boxes that form a line is called a line box.
The inline progression dimension ('width' in horizontal flow) of a line box is determined by its containing block. The block progression dimension ('height' in horizontal flow) of a line box is determined by the rules given in the section on line height calculations. A line box is generally tall (relative) enough for all of the boxes it contains. However, it may be taller than the tallest box it contains (if, for example, boxes are aligned so that baselines line up). When the block progression dimension of a box B is less than the similar dimension of the line box containing it, the alignment of B within the line box is determined by the baseline alignment properties.
When several inline boxes cannot fit within a single line box, they are distributed among two or more block-progression stacked line boxes. Thus, a paragraph is a stack of line boxes.
Line boxes are stacked together following the strategy determined by the 'line-stacking-strategy' property. Depending on the set value, line boxes can be stacked at constant spacing, in a grid manner or with enough space to accommodate all the line boxes. Using a constant spacing may create a 'bleeding' effect between line boxes.
A containing block defines a root inline element which wraps all the inline children of the block element, including the anonymous inline elements. It inherits the inline behaviors that are set for the block element (like 'line-height') and play an important role in some line stacking strategies.
Although margins, borders, and padding of non-replaced elements do not enter into inline box block-progression dimension calculation (and thus the line box calculation), they are still rendered around inline boxes. This means that if the block-progression dimension of a line box is shorter than the outer edges of the boxes it contains, backgrounds and colors of padding and borders may "bleed" into adjacent line boxes. However, in this case, some user agents may use the line box to "clip" the border and padding areas (i.e., not render them).
In general, the start edge of a line box touches the start edge of its containing block and the end edge touches the end edge of its containing block. However, floating boxes may come between the containing block edge and the line box edge. Thus, although line boxes in the same inline formatting context generally have the same inline progression advance (that of the containing block), they may vary if available inline-progression space is reduced due to floats. Line boxes in the same inline formatting context may vary in block-progression advance or not, depending on the line stacking strategy.
When the total inline-progression advance of the inline boxes on a line is less than the inline-progression dimension of the line box containing them, their inline-progression distribution within the line box is determined by the 'text-align' property. If that property has the value 'justify', the user agent may stretch the inline boxes as well.
Since an inline box may not exceed the inline-progression width of a line box, long inline boxes are split into several boxes and these boxes distributed across several line boxes. When an inline box is split, margins, borders, and padding have no visual effect where the split occurs. Formatting of margins, borders, and padding may not be fully defined if the split occurs within a bidirectional embedding.
Inline boxes may also be split into several boxes within the same line box due to bidirectional text processing.
<P>Several <EM>emphasized words</EM> appear <STRONG>in this</STRONG> sentence, dear.</P>
The P element generates a block box that contains five inline boxes, three of which are anonymous:
To format the paragraph, the user agent flows the five boxes into line boxes. In this example, the box generated for the P element establishes the containing block for the line boxes. If the containing block is sufficiently wide (relative) , all the inline boxes will fit into a single line box:
Several emphasized words appear in this sentence, dear.
If not, the inline boxes will be split up and distributed across several line boxes. The previous paragraph might be split as follows:
Several emphasized words appear in this sentence, dear.
or like this:
Several emphasized words appear in this sentence, dear.
In the previous example, the EM box was split into two EM boxes (call them "split1" and "split2"). Margins, borders, padding, or text decorations have no visible effect after split1 or before split2.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD> <TITLE>Example of inline flow on several lines</TITLE> <STYLE type="text/css"> EM { padding: 2px; margin: 1em; border-width: medium; border-style: dashed; line-height: 2.4em; } </STYLE> </HEAD> <BODY> <P>Several <EM>emphasized words</EM> appear here.</P> </BODY> </HTML>
Depending on the width of the P, the boxes may be distributed as follows:
Each inline box has a block-progression dimension which is derived from the following parameters: the 'text-height' and 'font-size' properties for non-replaced elements, the height or the width for replaced elements (depending on the text flow being horizontal or vertical respectively) and the stacked block-progression advance for inline-block elements (identical to what is done for block-level elements).
The block-progression dimension determines the position of the padding, border and margin for the element but does not necessarily determines the line stacking progression as this is also controlled by the 'line-stacking-strategy'.
Name: | text-height |
Value: | auto | font-size | text-size | max-size |
Initial: | auto |
Applies to: | inline elements and parents of element with display:ruby-text |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The 'text-height' property determine the block-progression dimension of the text content area of an inline box. Possible values:
When more than one font-size is used (this could happen when glyphs are found in different fonts), it is recommended that the largest font-size provides the em square and the cell-height.
Although the 'text-height' property does not apply directly to block elements, it applies to their anonymous children inline elements (if any).
The 'line-height' property allows to control the amount of leading space which is added before and after the block-progression dimension of either an inline box, a line box or both. The 'line-stacking-strategy' property value determines which effects are active. For example, there are line stacking strategies for which leading is not applied to inline boxes, but only to the line boxes. The sum of the possible leading space and the block progression dimension is called the extended block progression dimension. That extended value is not used for border, margin and padding placement but is used for vertical alignment (relative) and line box block progression dimension.
The leading for an inline element is defined as the difference between the block-progression dimension as determined by the 'text-height' property and the computed value of 'line-height'. Half the leading is called the half-leading, each half-leading is located before and after the block-progression dimension of the element. Depending on the value of the 'line-stacking-strategy', the 'line-height' value will specify the exact extended block-progression dimension of each box generated by the element or be ignored. (Except for inline replaced elements, where the block-progression dimension of the box is given by the 'height' or the 'width' property depending on the text flow.) When the line-height value is ignored for an inline element, the extended block progression dimension is identical to the block progression dimension. Anonymous inline elements use the 'text-height' and 'line-height' property values specified for their parent.
Depending on the value of the 'line-stacking-strategy', the 'line-height' value may provide a minimum or exact extended block-progression dimension for each generated inline box and the line boxes. How the leading space is distributed between the before-edge and the after-edge of inline elements within the line box depends on their vertical-align property value.
When applicable, the minimum extended block-progression dimension consists of a minimum ascent above the block's baseline and a minimum descent below it, exactly as if each line box starts with a zero-width (relative) inline box with the blocks' font and line height properties (what TEX calls a 'strut').
Empty inline elements generate empty inline boxes, but these boxes still have a line height, and thus may influence the line box block progression dimension, as if the empty box contained an infinitely narrow letter.
A inline box which otherwise would influence the line box extended progression dimension may be removed from the computation by using a special value of the line-height property: 'none'. This is equivalent to setting its line-height to the font-size of its ancestor block element.
Name: | line-height |
Value: | normal | <number> | <length> | <percentage> | none |
Initial: | normal |
Applies to: | all elements |
Inherited: | yes |
Percentages: | refer to the font size of the element itself |
Media: | visual |
Computed value: | see prose |
Values for this property have the following meanings:
Example(s):
The three rules in the example below have the same resultant line height:
DIV { line-height: 1.2; font-size: 10pt } /* number */ DIV { line-height: 1.2em; font-size: 10pt } /* length */ DIV { line-height: 120%; font-size: 10pt } /* percentage */
When an element contains text that is rendered in more than one font, user agents should determine the 'line-height' value according to the largest font size (when appropriate).
Note that replaced elements have a 'font-size' and a 'line-height' property, even if they are not used directly to determine the extended block progression dimension of the box: 'em' and 'ex' values are relative to values of 'font-size and percentage values for 'vertical-align' are relative to values of the extended block progression dimension.
When the 'line-height' value is less than the font size, the final inline box extended block progression dimension will be less than the font size and the rendered glyphs will "bleed" outside the box. If such a box touches the edge of a line box, the rendered glyphs will also "bleed" into the adjacent line box.
Line stacking is the mechanism by which a line box is determined for each line in a block and then these lines are stacked in the block progression direction resolving any spacing constraints between adjacent lines. The line-stacking strategy covers both the determination of the block progression dimension (height in horizontal flow) of a line box and the rules for spacing line boxes.
All line stacking strategies make use of the properties: 'font-size', 'text-height' and 'line-height'.
The line stacking properties are made of the following properties:
Name: | line-stacking-strategy |
Value: | inline-line-height | block-line-height | max-height | grid-height |
Initial: | inline-line-height |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property determines the line stacking strategy for stacked line boxes within a containing block element. The term 'stack-height' is used in the context of this property description to indicate the block-progression advance for the line boxes. Possible values:
When the line-stack strategy dictates that the inline element line-height be ignored, this means that for those elements only their block progression dimensions are considered for the stack-height, not their extended block progression dimensions.
Note. XSL has a similar property with the same name which use different but equivalent values: 'line-height' instead of 'inline-line-height', 'font-height' instead of 'block-line-height'. It also uses 'max-height. The value 'grid-height' is new to the CSS3 property.
Name: | line-stacking-ruby |
Value: | exclude-ruby | include-ruby |
Initial: | exclude-ruby |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property determines the line stacking method for block elements containing ruby annotation elements (element with 'display: ruby-text' or 'display: ruby-text-container'). In all cases the ruby base elements (elements with 'display: ruby-base' or display: ruby-base-container') are considered for line stacking. Possible values:
This property is ignored in two cases:
Name: | line-stacking-shift |
Value: | consider-shifts | disregard-shifts |
Initial: | consider-shifts |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property determines the line stacking method for block elements containing elements with base-shift. Possible values:
This property is ignored in two cases:
Note. XSL has a similar property with a different name: 'line-height-shift-adjustment' which use the same values.
Finally, the line stacking strategy can be used using the following shorthand:
Name: | line-stacking |
Value: | <'line-stacking-strategy'> || <'line-stacking-ruby'> || <'line-stacking-shift'> |
Initial: | see individual properties |
Applies to: | block-level elements |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
Baseline alignment describes the alignment of textual content and based on information contained in font tables associated with font resources. Additional descriptions for these font tables are provided in the CSS3 Fonts module.
The glyphs of a given script are positioned so that a particular point on each glyph, the alignment-point, is aligned with the alignment-points of the other glyphs in that script. The glyphs of different scripts are typically aligned at different points on the glyph. For example, Western glyphs are aligned on the bottoms of the capital letters, certain Indic glyphs (including glyphs from the Devanagari, Gurmukhi and Bengali scripts) are aligned at the top of a horizontal stroke near the top of the glyphs and East Asian glyphs are aligned either at the bottom or center of the EM box of the glyph. Within a script and within a line of text having a single font-size, the sequence of alignment-points defines, in the inline-progression-direction, a geometric line called a baseline. Western and most other alphabetic and syllabic glyphs are aligned to an "alphabetic" baseline, the above Indic glyphs are aligned to a "hanging" baseline and the East Asian glyphs are aligned to an "ideographic" baseline.
This figure shows the vertical position of the alignment-point for alphabetic and many syllabic scripts, illustrated by a Roman "A"; for certain Indic scripts, illustrated by a Gurmukhi syllable "ji"; and for ideographic scripts, illustrated by the ideographic glyph meaning "country". The thin black rectangle around the ideographic glyph illustrates the EM box for that glyph and shows the typical positioning of the "black marks" of the glyph within the EM box.
A baseline-table specifies the position of one or more baselines in the design space coordinate system. The function of the baseline table is to facilitate the alignment of different scripts with respect to each other when they are mixed on the same text line. Because the desired relative alignments may depend on which script is dominant in a line (or block), there may be a different baseline table for each script. In addition, different alignment positions are needed for horizontal and vertical writing modes. Therefore, the font may have a set of baseline tables: typically, one or more for horizontal writing-modes and zero or more for vertical writing-modes.
Examples of horizontal and vertical baseline positions. The thin lined box in each example is the "EM box". For the Latin glyphs, only the EM box of the first glyph is shown. Example 1 shows typical Latin text written horizontally. This text is positioned relative to the alphabetic baseline, shown in blue. Example 2 shows a typical ideographic glyph positioned on the horizontal ideographic baseline. Note that the EM Box is positioned differently for these two cases. Examples 3 and 4 show the same set of baselines used in vertical writing. The Latin text, example 3, is shown with a glyph-orientation of 90 degrees which is typical for proportionally space Latin glyphs in vertical writing. Even though the ideographic glyph in Example 4 is positioned on the vertical ideographic baseline, because it is centered in the EM box, all glyphs with the same EM Box are centered, vertically, with respect to one another.
The font tables for a font include font characteristics for the individual glyphs in the font. CSS assumes that the font tables include, for each glyph in the font, one width value, one alignment-baseline and one alignment-point for the horizontal writing-modes. If vertical writing-modes are supported, then each glyph must have another width value, alignment-baseline and alignment-point for the vertical writing-modes. (Even though it is specified as a width, for vertical writing-modes the width is used in the vertical direction.)
The script to which a glyph belongs determines an alignment-baseline to which the glyph is to be aligned. The position of this baseline in the design space coordinate system determines the default block progression direction position of the alignment-point. The inline progression direction position of the alignment-point is on the start-edge of the glyph.
This figure shows glyphs from three different scripts, each with its EM box and within the EM box, the baseline table applicable to that glyph. The alignment-point of each glyph is shown by an "X" on the start edge of the EM box and by making alignment-baseline blue. The baseline-table of the parent element of the characters that mapped to these glyphs is shown as a set of dashed lines.
The baseline alignment properties control the alignment of child element with respect to their parent. The positions of these baselines are illustrated in the following figure:
This figure shows samples of Gurmukhi (a hanging Indic script), Latin and ideographic scripts together with most of the baselines defined below. The thin line around the ideographic glyphs symbolizes the EM box in which these glyphs are centered. In this figure, the position of the "text-before-edge" and "text-after-edge" baselines is computed assuming that the "alphabetic" baseline is the dominant-baseline. The "central" baseline has been omitted from the figure, but it lies halfway between the "text-before-edge" and "text-after-edge" baselines, just about where the "math" baseline is shown.
The baseline-identifiers below are used in this specification. Some of these are determined by baseline-tables contained in a font as described in the section describing the baseline information provided by fonts. Others are computed from other font characteristics as described below. Whether determined by the font or computed, a derived baseline-table is constructed with positions of each of the baselines below.
This identifies the baseline used by most alphabetic and syllabic scripts. These include, but are not limited to, many Western, Southern Indic, Southeast Asian (non-ideographic) scripts.
This identifies the baseline used by ideographic scripts. For historical reasons, this baseline is at the bottom of the ideographic EM box and not in the center of the ideographic EM box. See the "central" baseline. The ideographic scripts include Chinese, Japanese, Korean, and Vietnamese Chu Nom.
This identifies the baseline used by certain Indic scripts. These scripts include Devanagari, Gurmukhi and Bengali.
This identifies the baseline used by mathematical symbols.
This identifies a computed baseline that is at the center of the EM box. This baseline lies halfway between the text-before-edge and text-after-edge baselines.
Note. For ideographic fonts, this baseline is often used to align the glyphs; it is an alternative to the ideographic baseline.
This identifies a baseline that is offset from the alphabetic baseline in the shift-direction by 1/2 the value of the x-height font characteristic. The position of this baseline may be obtained from the font data or, for fonts that have a font characteristic for "x-height", it may be computed using 1/2 the "x-height". Lacking either of these pieces of information, the position of this baseline may be approximated by the "central" baseline.
This identifies the before-edge of the EM box. The position of this baseline may be specified in the baseline-table or it may be calculated.
Note. The position of this baseline is normally around or at the top of the ascenders, but it may not encompass all accents that can appear above a glyph. For fonts with ascenders, the value of the "ascent" font characteristic is used. For ideographic fonts, the position of this baseline is normally 1 EM in the shift-direction from the "ideographic" baseline. However, some ideographic fonts have a reduced width in the inline-progression-direction to allow tighter setting. When such a font, designed only for vertical writing-modes, is used in a horizontal writing-mode, the "text-before-edge" baseline may be less than 1 EM from the text-after-edge.
This identifies the after-edge of the EM box. The position of this baseline may be specified in the baseline-table or it may be calculated.
Note. For fonts with descenders, the position of this baseline is normally around or at the bottom of the descenders. For these fonts the value of the "descent" font characteristic is used. For ideographic fonts, the position of this baseline is normally at the "ideographic" baseline.
There are, in addition, two computed baselines that are only defined for line boxes: 'before-edge' and 'after-edge'. For each line box, there is a dominant-baseline, a baseline-table and a baseline-table font-size which are those of the nearest block-level ancestor element and are applied to its root inline element. Depending on the 'line-stacking-strategy' being used, the line stacking progression (also called stack-height) can be different from the line block progression dimension. The 'before-edge' and 'after-edge' baselines are always based on the block progression dimension and are in fact part of its determination.
For an inline element, the extended inline box includes the maximum extent of their static or relative positioned children located in the same line box and may include leading specified by their line-height value. Depending on the line-stacking-strategy value, the extended line box may have a different block progression dimension. For replaced elements the margin extents are always added.
The following text explains the interaction between the line-stacking-strategy and the various baseline alignment parameters.
The "before-edge" and "after-edge" baselines are defined as follows.
The offset of the "before-edge" baseline of the line from the dominant-baseline of the line is determined by ignoring all extended inline boxes whose alignment-baseline is either "before-edge" or "after-edge". For the "before-edge", extents are measured from the dominant-baseline in the direction toward the top (relative) of the extended inline box. The "before-edge" baseline offset is set to the maximum extent of the "before-edges" of the extended inline boxes of the remaining areas. If all the extended inline boxes in a line box are aligned either to the "before-edge" or to the "after-edge", then use the offset of the "text-before-edge" baseline of the line as the offset of the "before-edge" baseline of the line.
The offset of the "after-edge" baseline of the line from the
dominant-baseline of the line is determined by ignoring all extended inline boxes
whose alignment-baseline is after-edge
. For the "after-edge",
extents are measured from the dominant-baseline in the direction toward the
bottom (relative) of the extended inline box. The "after-edge" baseline offset is
set to the negative of the maximum of (1) the maximum extent of the
"after-edges" of the remaining extended inline boxes and (2) the
maximum height of the extended inline boxes that are ignored
minus the offset of the "before-edge" baseline of the line.
Note. If all the extended inline boxes in a line box are aligned to the "after-edge" then the specification for the "before-edge" will set the "before-edge" baseline to coincide with the "text-before-baseline" of the line. Then, case (2) above will determine an offset to the "bottom-edge" baseline that will align the "before-edge" of the box with the greatest height to its allocation-rectangle to "before-edge" baseline.
Note. The above specifications for "before-edge" and "after-edge" have the following three properties: (1) all extended inline boxes are below the "before-edge", (2) all extended inline boxes are above the "after-edge", and (3) the distance between the "before-edge" and the "after-edge" cannot be decreased without violating (1) or (2). The specified placement of the "before-edge" and "after-edge" is not the only way that (1)-(3) can be satisfied, but it is the only way they can be satisfied with the smallest possible offset to the "before-edge".
For the purpose of before-edge and after-edge baseline computation, inline boxes include the maximum extent of their static or relative positioned children located in the same line box. Maximum alignment extents are measured by including the half leading extent in the appropriate direction for non replaced elements and by using the margin extents for replaced elements.
Examples showing "before-edge" and "after-edge" alignment:
The rectangles with lines or arrows are images with an intrinsic size as shown. The rectangles with no arrows represent images that receive the default, dominant baseline, alignment. The alignment of the other rectangles is at the furthest point from the arrow head (which is in the middle when there are two arrowheads). Examples 1 and 2 show the "before-edge" alignment is determined by the tallest non-"before-edge" aligned objects: in example 1 this is the default aligned, arrowhead free rectangular image and in example 2 this is the double headed arrow rectangle. Examples 3 and 4 show defaulting to the "text-before-edge" when all the boxes have either "before-edge" or "after-edge" alignment. In example 3, the images with "before-edge" alignment has a taller member than do the "after-edge" aligned images. In example 4, the tallest image is in the "after-edge" aligned set. Example 5 is a repetition of example 2 with largest image being an "after-edge" aligned image.
There are also four baselines that are defined only for horizontal writing-modes.
This baseline is the same as the "before-edge" baseline in a horizontal writing-mode and is undefined in a vertical writing mode.
This baseline is the same as the "text-before-edge" baseline in a horizontal writing-mode and is undefined in a vertical writing mode.
This baseline is the same as the "after-edge" baseline in a horizontal writing-mode and is undefined in a vertical writing mode.
This baseline is the same as the "text-after-edge" baseline in a horizontal writing-mode and is undefined in a vertical writing mode.
The alignment of an element with respect to its parent is determined by three things: the scaled-baseline-table of the parent and the alignment-baseline and alignment-point of the element being aligned. Prior to alignment, the scaled-baseline-table of the parent may be shifted. The property specifications below provide the information necessary to align the parent and child elements.
There are four properties that control alignment of elements to the above set of baselines: 'dominant-baseline', 'alignment-baseline', 'baseline-shift' and 'alignment-adjust'. These properties are all independent and are designed so that typically only the specification of one of the properties is needed to achieve a particular alignment goal.
The primary baseline alignment property is the 'dominant-baseline' property. This property sets the scaled-baseline-table as a compound value with the three following components:
Because the value of the 'font-family' property is a list of fonts, to insure a consistent choice of baseline-table we define the nominal font in a font list as the first font in the list for which a glyph data is available. This is the first that could contain a glyph for each character encountered. (For this definition, glyph data is assumed to be present if a font substitution is made or if the font is synthesized.) This definition insures a content independent determination of the font and baseline table that is to be used.
For convenience, the specification will sometimes refer to the baseline identified by the dominant-baseline-identifier component of the "dominant-baseline" property as the "dominant baseline" (in an abuse of terminology).
The model also assumes that each glyph has an 'alignment-baseline' value which specifies the baseline with which the glyph is to be aligned. (The 'alignment-baseline' is called the "Baseline Tag" in the OpenType baseline-table description.) The initial value of the 'alignment-baseline' property uses the baseline identifier associated with the given glyph. Alternate values for 'alignment-baseline' can be useful for glyphs such as a "*" which are ambiguous with respect to script membership.
The model assumes that the font from which the glyph is drawn also has a baseline table, the font baseline-table. This baseline table has offsets in units-per-em from the (0,0) point to each of the baselines the font knows about. In particular, it has the offset from the glyph's (0,0) point to the baseline identified by the 'alignment-baseline'.
The offset values in the baseline-table are in "design units" which means fractional units of the EM. CSS calls these "units-per-em". Thus, the current 'font-size' is used to determine the actual offset from the dominant baseline to the alternate baselines.
The glyph is aligned so that its baseline identified by its 'alignment-baseline' is aligned with the baseline with the same name from the dominant baseline-table.
The offset from the dominant baseline of the parent to the baseline identified by the 'alignment-baseline' is computed using the dominant baseline-table and dominant baseline-table font-size. The font baseline-table and font-size applicable to the glyph are used to compute the offset from the identified baseline to the (0,0) point of the glyph. This second offset is subtracted from the first offset to get the position of the (0,0) point in the shift direction. Both offsets are computed by multiplying the baseline value from the baseline-table times the appropriate font-size value.
If the 'alignment-baseline' identifies the dominant baseline, then the first offset is zero and the glyph is aligned with the dominant baseline; otherwise, the glyph is aligned with the chosen alternate baseline.
The third baseline alignment property is the 'baseline-shift' property. Like the properties other than the "dominant-baseline" property, this property does not change the baseline-table or the baseline-table font-size. It does shift the whole baseline table of the parent element so that when an inner inline element is aligned to one of the parents baselines, the position of the inner inline element is shifted.
The fourth alignment property is the 'alignment-adjust' property. This property is primarily used for replaced elements. The "alignment-adjust" property allows the author to assign where, on the start-edge of the object, the alignment point for that element lies.
For alignment purposes, the margins are added to the replaced elements dimensions.
In addition to the following definition of these properties, an informative appendix: B provides usage examples of these properties.
Name: | dominant-baseline |
Value: | auto | use-script | no-change | reset-size | alphabetic | hanging |
ideographic | mathematical | central | middle | text-after-edge | text-before-edge |
Initial: | auto |
Applies to: | inline-level elements (but see prose) |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The 'dominant-baseline' property is used to determine or re-determine a scaled-baseline-table. A scaled-baseline-table is a compound value with three components:
Some values of the property re-determine all three values; other only reestablish the baseline-table font-size. Values for the property have the following meaning:
Note: Computed baselines do not (necessarily) choose a defining baseline table from the nominal font. The expected baseline-tables that a font would have are those that correspond to the defined baselines. The catch is that the positions of the defined baselines -- the 'hanging', 'alphabetic', 'mathematical' and 'ideograph' baselines -- can be specified differently for different choices of which of these baselines is dominant. That is, the absolute value of the offset of an alphabetic baseline from the ideographic baseline in ideographic text may be different from the offset of the ideographic baseline from the alphabetic baseline in alphabetic text. Therefore, it matters which baseline-table from the nominal font is used for the defined baselines.
If there is no baseline-table in the nominal font or if the baseline-table lacks an entry for the desired baseline, then the user agent may use heuristics to determine the position of the desired baseline.
Name: | alignment-baseline |
Value: | baseline | use-script | before-edge | text-before-edge | after-edge |
text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical |
Initial: | baseline |
Applies to: | inline-level elements |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
This property specifies how an inline-level element is aligned with respect to its parent. That is, to which of the parent's baselines the alignment point of this element is aligned. Unlike the 'dominant-baseline' property the 'alignment-baseline' property has no effect on its children dominant-baselines.
Note: The 'alignment-adjust' property specifies how the alignment point is determined and defaults to the baseline with the same name as the computed value of the alignment-baseline property.
Except for 'use-script', all baseline values refer to the respective baseline-identifier components of the dominant-baseline of the parent, and glyphs within the element are aligned similarly to the element itself. The description for 'use-script' covers these points specifically. The property values have the following meanings:
The values: before-edge, text-before-edge, after-edge and text-after-edge all work relatively to the writing-mode property values. For example 'before-edge' means 'top' in an horizontal writing mode and 'right' in a vertical writing mode.
Note. The reason why 'baseline' is the initial value instead of 'use-script' (called 'auto' in the similar XSL property) has to do with the fact that most fonts today are designed with an alignment point located at the 'alphabetical' level, even for glyphs belonging to non Latin scripts. User agents have to deal with that constraint, and therefore they use the 'baseline' value as initial.
Name: | alignment-adjust |
Value: | auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length> |
Initial: | auto |
Applies to: | inline-level elements |
Inherited: | no |
Percentages: | refers to the 'line-height' of the element |
Media: | visual |
Computed value: | see text |
The 'alignment-adjust' property allows more precise alignment of elements, such as graphics, that do not have a baseline-table or lack the desired baseline in their baseline-table. With the 'alignment-adjust' property, the position of the baseline identified by the 'alignment-baseline' can be explicitly determined. It also determines precisely the alignment point for each glyph within a textual element. The user agent should use heuristics to determine the position of a non existing baseline for a given element.
Values for the property have the following meaning:
Name: | baseline-shift |
Value: | baseline | sub | super | <percentage> | <length> |
Initial: | baseline |
Applies to: | inline-level elements |
Inherited: | no |
Percentages: | refers to the 'line-height' of the parent element |
Media: | visual |
Computed value: | see text |
The 'baseline-shift' property allows repositioning of the dominant-baseline relative to the dominant-baseline. The shifted object might be a sub- or superscript. Within the shifted element, the whole baseline table is offset; not just a single baseline. For sub- and superscript, the amount of offset is determined from the nominal font of the parent.
Values for the property have the following meaning:
Note. Although it may seem that 'baseline-shift' and
'alignment-adjust' properties are doing
the same thing, there are important differences. For 'alignment-adjust'
the percentage values refer to the 'line-height' of the element being
aligned. For 'baseline-shift the percentage values refer to the 'line-height'
of the parent element. Similarly, it is the 'sub' and 'super' offsets of the
parent that are used to align the shifted baseline rather than the 'sub' and
'super' offsets of the element being positioned. To ensure a consistent sub-
or superscript position, it makes more sense to use the parent as the
reference rather than the subscript element which may have a changed
"line-height" due to "font-size" changes in the sub- or superscript
element.
Using the "alignment-adjust" property is more suitable for positioning
elements, such as graphics, that have no internal textual structure. Using
the "baseline-shift" property is intended for sub- and superscripts where the
positioned element may itself be textual. The baseline-shift provides a way
to define a specific baseline offset other than the named offsets that are
defined relative to the dominant-baseline. In addition, having
"baseline-shift" makes it easier for a tool to generate the relevant
properties; many formatting programs already have a notion of baseline shift.
Name: | vertical-align |
Value: | auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> |
Initial: | not defined for shorthand properties |
Applies to: | inline-level and 'table-cell' elements |
Inherited: | no |
Percentages: | refers to the 'line-height' of the element itself |
Media: | visual |
Computed value: | see text |
This property affects the vertical positioning of the inline boxes generated by an inline-level element inside a line box. The following values only have meaning with respect to a parent inline-level element, or to a parent block-level element, if that element generates anonymous inline boxes; they have no effect if no such parent exists.
Note. Values of this property have slightly different meanings in the context of tables. Please consult the section on table height algorithms for details.
The remaining values refer to the line box in which the generated box appears:
The 'vertical-align' property values affect the baseline alignment properties for which it is a shorthand in the following manner:
vertical-align value | alignment-baseline | alignment-adjust | baseline-shift | dominant-baseline |
---|---|---|---|---|
auto | baseline | auto | baseline | auto |
use-script | use-script | auto | auto | auto |
baseline | baseline | auto | baseline | alphabetic (if no parent or
different flow from parent) no-change (otherwise) |
sub | baseline | auto | sub | auto |
super | baseline | auto | super | auto |
top | before-edge | auto | baseline | auto |
text-top | text-before-edge | auto | baseline | auto |
central | central | auto | baseline | auto |
middle | middle | auto | baseline | auto |
bottom | after-edge | auto | baseline | auto |
text-bottom | text-after-edge | auto | baseline | auto |
<percentage> | baseline | <percentage> | baseline | auto |
<length> | baseline | <length> | baseline | auto |
Name: | inline-box-align |
Value: | initial | last | <integer> |
Initial: | last |
Applies to: | inline-block-level elements |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value (except for initial and inherit) |
The 'inline-box-align' property determines which line of a multi-line inline block align with the previous and next inline elements within a line. The alignment strategy for the inline lock itself (i.e. the definition of it alignment point and which parent baseline should be used for the alignment) is determined by the inline block element baseline alignment properties applicable to the line being used for the alignment. This property has no effect for single line inline block. Possible values:
On a block element containing inline elements, the initial line is very often presented differently. For example it may use a difference typeface, a color, font-size or even casing (like all uppercase). The presentation of that initial line can be controlled by applying a limited set of style properties to the ::first-line pseudo element. Only the following properties can be applied to the ::first-line pseudo elements:
Although there is no properties only applicable to ::first-line pseudo elements, in essence the 'text-indent' property which is applied to 'block-level' elements is in fact only effective on the first line of the block element.
Drop initial is a typographic effect emphasizing the initial letter(s) of a block element with a presentation similar to a 'floated' element. It can be described as the combination of the following effects:
For the purpose of drop initial, an initial letter has two alignment points: an 'after' alignment point and a 'before' alignment point. (For writing-mode:lr-tb, 'after' corresponds to bottom and 'before' to 'top').
The 'after' alignment point connects with one of the alignment point of the nth line of the block element of which the initial letter is part of. The value 'n' is the number of lines by which the initial letter is dropped. That connection point is called the primary connection point. The union of the two alignment lines makes a connection line.
If no drop initial size is explicitly provided, there is a secondary connection point where the 'before' alignment points connects with one of the alignment point of the initial line. In that case the initial letter is totally sunken.
If a drop initial size is provided, there is no secondary connection point as it would result otherwise in an over constraint situation. In that case the initial letter may not be totally sunken, especially if the size is provided in 'line' unit with a number larger than the drop.
The values provided above result in the creation of an 'ink box' which is filled by the initial letter. Depending on the selected alignment points, part of the glyphs may bleed beyond the ink box.
The character content of the drop initial influences greatly how the drop initial letters are best aligned with the rest of the block element content.
The CSS mechanism to 'select' the drop initial content is the ::first-letter pseudo element. The first letter is defined as including all starting punctuation characters (defined in Unicode as 'open' (Ps), 'close' (Pe) and 'other' (Po), if any, followed by the first non-punctuation character cluster. A character cluster may be a single character, a combining sequences (base character followed by combining characters) or a stacked set of characters (like in Thai).
Only the following properties can be applied to the ::first-letter pseudo elements:
In addition, one property: 'text-indent' although applying to block-level elements is in fact effective on its first line of text and has therefore an influence on the indentation of the first-letter versus the start edge of the containing block. Using the 'text-indent' allows the correction of optical effect (like uppercase 'O') or even pushing the starting piece of the initial letter in a 'virtual' margin.
Editor's note: Additional drop initial features are desirable but are not described in this specification:
bleeding between the drop initial and its related block content,
tight wrap between the drop initial and its related block content
multiple letter with author control (not possible with ::first-letter)
multiple size and alignment within the drop initial (required for French opening guillemet)
Some of these features (multiple letter and size) could be achieved by introducing a new display value, like 'display: drop-initial' which when applied to an inline element part of the first line could make it behave like a drop initial inline element.
The following figure shows first a simple case of a three line drop initial, and second a case of a two line drop initial but with a three line size initial letter.
Typical drop initial cases: sunken cap and partially raised cap
The bottom horizontal line in the first example shows the alignment between the baseline of the initial letter and the baseline of the third line of its block element. The primary connection point occurs at the intersection of these baselines between the two boxes (the third line box and the initial letter box). The top horizontal line shows a connection point between the top of the ink of the initial letter and the text-before-edge baseline of the initial line. Alternatively, instead of the text-before-edge baseline, a new computed alignment could be used which correspond loosely to the maximum caps-height of the initial line.
Typically the ink of drop initial characters 'fills' the space between the baseline and the text-before-edge, therefore 'taller' characters are processed accordingly. This is shown in the first two pictures of the following figure, using first an accentuated letter, and then a letter without accent.
Drop initial with accent and without accent
The third picture shows a more correct effect with the acute accent drawn in the upper padding area. This effect is realized by having the secondary connection point between the initial letter caps height and the maximum caps height of the initial line.
Typically characters are stretched in both direction to fill the space between the primary and secondary connection lines (in the absence of an explicit drop initial size). Even if the character has no 'ink' at the primary connection line, the stretching is performed as if there were a 'virtual' point at that level. The following figure demonstrates the effect for the hyphen-minus character. The other two characters demonstrate the variable stretching made by the drop initial effect.
Drop initial with period, hyphen and exclamation point
For characters that have only ink 'after' (below) their baseline there is really no good strategy. It may be better to use the font EM square as reference for symbols that have no ink at the primary connection line.
Some characters are always expected to be shown as if using their full EM square, even in drop initial situation. For example, this is the case for all ideograms and related characters like the Japanese Kana characters. The following figure shows how the ink of the character representing the number one in CJK (middle picture) is not stretched to hit the top of the text-before-edge of the initial line, but is instead stretched following the same ratio as the character in the left picture. The picture on the right shows that drop initial can also be used in vertical flow.
Drop initial with ideographic characters
Drop initial characters can be aligned using a variety of baselines for the drop initial alignment point used for the primary connection point. The examples above used the alphabetic and the ideographic baselines. The following figures compares the usage of the text-after-edge baseline (picture on the left) and the alphabetic baseline (picture on the right). Note that when the alphabetic baseline is used for characters that have ink below the baseline, the actual drop initial effect may occur through many more lines to accommodate the text-after-edge constraint.
Drop initial with lowercase characters
Drop initial with uppercase character with descender
The drop initial effect may also be used for writing systems which use different alignment strategies. For example, in Devanagari the hanging baseline may be preferred. In that case the primary connection point connects the text-after-edge of the initial letter with the text-after-edge of the nth line, but the secondary connection point connects the hanging baselines of the initial letter and the initial line. This is shown in the following figure:
Drop initial with hanging devanagari characters
The drop initial effect is typically based on a number of lines, i.e. the combined line-height adjusted by the alignment strategies for the connection lines is used to determine the default size of the drop initial character. However there is a potential circular issue as the activation of the effect modifies the content of the lines and therefore may affect their line-height. The recommended strategy is to determine the drop initial character size using the initial combined line height and to possibly stretch the character along the new baseline if the combined line height is modified by the drop initial effect. The following figure shows the initial text on the left, an incorrect drop initial effect in the middle (no stretch applied) and a correct effect on the right (stretch applied).
Drop initial with variable line heights
Name: | drop-initial-value |
Value: | initial | <integer> |
Initial: | initial |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-value' property is the basic property that activates a drop-initial effect. By providing a value different than 'initial or '1', the primary connection point is moved after the initial line. Possible values:
Name: | drop-initial-size |
Value: | auto | <line> | <length> | <percentage> |
Initial: | auto |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | refer to combined line height size as provided by drop-initial-value |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-size' property controls the partial sinking of the initial letter. Using any other value than 'auto' removes the secondary connection line constraint. Possible values:
Name: | drop-initial-after-align |
Value: | <'alignment-baseline'> |
Initial: | baseline |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-after-align' property determines which alignment line within the nth line box (n being defined by the 'drop-initial-value' property) is used at the primary connection point with the initial letter box. The values are the same as the 'alignment-baseline' property values.
Name: | drop-initial-after-adjust |
Value: | central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length> |
Initial: | text-after-edge |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | refer to combined line height size as provided by drop-initial-value |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-after-adjust' property sets the alignment point of the drop initial for the primary connection point. Possible values:
Name: | drop-initial-before-align |
Value: | caps-height | <'alignment-baseline'> |
Initial: | caps-height |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-before-align' property determines which alignment line within the initial line box is used at the secondary connection point with the initial letter box. This property is only effective is the value of the 'drop-initial-size' property is 'auto'. Possible values:
Name: | drop-initial-before-adjust |
Value: | before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length> |
Initial: | text-before-edge |
Applies to: | ::first-letter pseudo element |
Inherited: | no |
Percentages: | refer to combined line height size as provided by drop-initial-value |
Media: | visual |
Computed value: | specified values (except for initial and inherit) |
The 'drop-initial-before-adjust' property sets the alignment point of the drop initial for the secondary connection point. This property is only effective is the value of the 'drop-initial-size' property is 'auto'. Possible values:
In addition to the specified values, all properties take the initial and inherit values
Property | Values | Initial | Applies to | Inh. | Percentages | Media |
---|---|---|---|---|---|---|
alignment-adjust | auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length> | auto | inline-level elements | no | refers to the 'line-height' of the element | visual |
alignment-baseline | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical | baseline | inline-level elements | no | N/A | visual |
baseline-shift | baseline | sub | super | <percentage> | <length> | baseline | inline-level elements | no | refers to the 'line-height' of the parent element | visual |
dominant-baseline | auto | use-script | no-change | reset-size | alphabetic | hanging | ideographic | mathematical | central | middle | text-after-edge | text-before-edge | auto | inline-level elements (but see prose) | no | N/A | visual |
drop-initial-after-adjust | central | middle | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length> | text-after-edge | ::first-letter pseudo element | no | N/A | visual |
drop-initial-after-align | <'alignment-baseline'> | baseline | ::first-letter pseudo element | no | N/A | visual |
drop-initial-before-adjust | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | hanging | mathematical | <percentage> | <length> | text-before-edge | ::first-letter pseudo element | no | N/A | visual |
drop-initial-before-align | caps-height | <'alignment-baseline'> | caps-height | ::first-letter pseudo element | no | N/A | visual |
drop-initial-size | auto | <line> | <length> | <percentage> | auto | ::first-letter pseudo element | no | refers to combined line height size as provided by drop-initial-value | visual |
drop-initial-value | initial | <integer> | initial | ::first-letter pseudo element | no | N/A | visual |
inline-box-align | initial | last | <integer> | last | inline-block-level elements | no | N/A | visual |
line-height | normal | number | <length> <percentage> | none | normal | all elements and generated content | yes | refer to the font size of the element itself | visual |
line-stacking | <'line-stacking-strategy'> || <'line-stacking-ruby'> || <'line-stacking-shift'> | see individual properties | block-level elements | yes | N/A | visual |
line-stacking-ruby | exclude-ruby | include-ruby | exclude-ruby | block-level elements | yes | N/A | visual |
line-stacking-shift | consider-shifts | disregard-shifts | consider-shifts | block-level elements | yes | N/A | visual |
line-stacking-strategy | inline-line-height | block-line-height | max-height | grid-height | inline-line-height | block-level elements | yes | N/A | visual |
text-height | auto | font-size | text-size | max-size | auto | inline elements and parents of element with display:ruby-text | yes | N/A | visual |
vertical-align | auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> | not defined for shorthand properties | inline-level and 'table-cell' elements | no | refers to the 'line-height' of the element itself | visual |
The following properties are mentioned in this module, but are defined elsewhere:
There are 3 modules defined by this chapter:
CSS1 line model:
CSS2 line model:
CSS3 line model:
The CSS1 line module is made of the following properties/values:
Name | Values | Initial | Applies to | Inherited | Percentages | Media groups |
---|---|---|---|---|---|---|
'line-height' | normal | <number> | <length> | <percentage> | normal | all elements | yes | relative to the font-size of the element itself | N/A |
'vertical-align' | baseline | sub | super | top | text-top | middle | bottom | text-bottom | <percentage> | baseline | inline-level elements | no | N/A | N/A |
The following table describes the CSS2 text module. Because all properties have added the 'inherit' value and have a media type, all CSS1 properties have been specified below as well. In addition, the 'vertical-align' has a new value: <length>. Properties that applies to all elements also applies to generated content. Finally, 'vertical-align' also applies to table-cell elements.
.Name | Values | Initial | Applies to | Inherited | Percentages | Media groups |
---|---|---|---|---|---|---|
'line-height' | normal | <number> | <length> | <percentage> | normal | all elements and generated content | yes | relative to the font-size of the element itself | N/A |
'vertical-align' | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> | inherit | baseline | inline-level and table-cell elements | no | N/A | visual |
The CSS3 module adds the following properties:
It also modifies the following properties as described:
The following appendix shows some examples of baseline alignment, exercising the related properties .
A simple example of alignment is shown in the following figure. The figure shows the presentation of two inline elements, one inside the other. These inline elements make up the content of a line in a block where the writing-mode is "lr-tb" and the font is "Helvetica". The structure of the example is as follows:
<p><span class="outer">Apex <span class="inner">Top</span></span></p>
with the style being defined as:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; }
The other baseline alignment initial values apply. Since a horizontal writing-mode is in use, the dominant-baseline-identifier is set to "alphabetic" and the baseline-table is taken from the nominal-font for the block in which the line appears, which, in this case, is Helvetica.
In the figure, the positions of the baselines relative to the current font size are shown as red (staff) lines. These lines are labeled with abbreviations of the names of the baselines (e.g., TBE for "text-before-edge"). The baseline identified by the dominant-baseline-identifier (A) is shown in blue. There is a break in the staff lines to separately show the inner inline element. This is not necessary for this example, but this distinction will become important in subsequent examples.
The "alignment-baseline" property is the primary control on the positioning of an inner element with respect to its parent. The initial value of the "alignment-baseline" property is "baseline". This aligns the dominant-baseline of the inner inline element with the dominant baseline of the outer inline element. This is shown by the short blue line that connects the two separated staffs (A) in the figure.
The glyphs that are in the content of the two elements are aligned based on the script to which the glyph belongs. Since this example only has Latin glyphs, they are aligned to the "alphabetic" baseline.
An inner inline element containing Latin characters aligned to an outer inline element also containing Latin characters.
In the next figure, the content of the inner inline element is in Gurmukhi, the script of the Punjabi language. The Gurmukhi syllables are read as "guru". Rather than use Unicode values for these characters, they are symbolized by placing the Latin transliteration in italic type. The structure of the example becomes (assuming the same style):
<p><span class="outer">Apex <span class="inner">guru</span></span></p>
The only change from the previous example is that the glyphs of the Gurmukhi script are aligned to the "hanging" baseline of the inner inline element. The alignment of that element itself, with respect to the outer inline element, is unchanged. The "hanging" baseline position is computed from the font-table part of the dominant-baseline set of the parent element (in this case the outer inline element which is getting itself the set from its parent, the block element).
An inner inline element containing Gurmukhi characters aligned to an outer inline element containing Latin characters.
In the next figure, fragments of the text of the previous examples make up the content of the outer inline element. The inner inline element has a change of font-size, however. The structure is:
<p><span class="outer">Apguru <span class="inner">Exji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.inner { font-size: .75em; }
In this example, the alignment of the inner inline element itself does not change, nor does the alignment of the smaller glyphs inside the inner element. The Latin glyphs are still aligned to the "alphabetic" baseline and the Gurmukhi glyphs, which are pronounced "ji" are aligned to the "hanging" baseline. Note also that just changing the "font-size" property did not change the baseline-table in effect in the inner inline element.
The inner inline element has a reduced font-size.
The next figure is equivalent to the previous example with the Gurmukhi character replaced by ideographic characters. These are aligned to the "ideographic" baseline.
The previous figure redone with ideographic glyphs instead of Gurmukhi glyphs. The EM boxes are shown for the ideograms to clarify the alignment of these glyphs.
To change the scaling of the lines of the baseline table, it is necessary to use the "dominant-baseline" property on the inner inline element. The value of "reset-size" causes the baseline-table font-size to be reset from the font-size of the element on which the "dominant-baseline" property appears. The next figure shows the effect of this, using the structure:
<p><span class="outer">Apguru <span class="inner">Exji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.inner { font-size: .75em; dominant-baseline: reset-size; }
The alignment of the inner inline element, with respect to the outer inline element, is still determined by aligning the dominant baselines (alphabetic). But, the baseline-table of the inner inline element has been rescaled to the font-size of the inner inline element. Hence the smaller glyphs align with each other.
The baseline-table of the inner inline element has been resized to match the font-size of the inner inline element.
But, what if it is more important that the small Gurmukhi glyphs align with the large Gurmukhi glyphs than having the Latin glyphs align. There are at least two ways to achieve this. The structure:
<p><span class="outer">Apguru <span class="inner">Exji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.outer {dominant-baseline: hanging } span.inner { font-size: .75em; dominant-baseline: reset-size; }
is illustrated in the next figure. The "hanging" baseline becomes the dominant baseline and the initial value of the "alignment-baseline" property causes the (newly) dominant "hanging" baselines to be aligned as is shown by the connection of the blue baselines.
Changing the dominant baseline to the "hanging" baseline causes the inner inline element to be aligned on its parent's "hanging" baseline.
It is also possible to achieve the effect of the above figure without changing the dominant baseline. Instead it is sufficient to explicitly specify that the inner inline element is aligned on its "hanging" baseline. This is done by:
<p><span class="outer">Apguru <span class="inner">Exji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.inner { font-size: .75em; dominant-baseline: reset-size; alignment-baseline: hanging; }
The only change this approach would make in the above figure is to color the "hanging" baseline red and keep the "alphabetic" baseline as the (blue) dominant baseline. This baseline in the inner inline element would not (as it does not in the above figure) align with the "alphabetic" baseline in the outer inline element.
Another baseline alignment property is the "baseline-shift" property. Like the properties other than the "dominant-baseline" property, this property does not change the baseline-table or the baseline-table font-size. It does shift the whole baseline table of the parent element so that when an inner inline element is aligned to one of the parents baselines, the position of the inner inline element is shifted. This is illustrated in the next figure. The structure which creates this figure is:
<p><span class="outer">Apex <span class="inner">1ji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.inner { baseline-shift: super; }
Because the whole set of baseline-table staff lines are shifted to the position of the superscript baseline: it does not matter to which baseline the glyphs in the superscript are aligned. The European number "1" is aligned to the "alphabetic" baseline and the Gurmukhi syllable "ji" is aligned to the "hanging" baseline.
Using a "baseline-shift" for a superscript (or a subscript).
It is more common for the font-size of the superscript text to be smaller than the font-size of the text to which it is appended. Consider:
<p><span class="outer">Apex <span class="inner">1ji</span></span></p>
with the following style:
p { writing-mode: lr-tb; font: Helvetica; } span { alignment-baseline: use-script; } span.inner { baseline-shift: super; font-size: .75em; }
Because changing the font-size on a superscript (or subscript) is common, this is the one case where changing the font-size does cause the baseline-table font-size to be reset when the "dominant-baseline" property has its initial value. After the rescaling, the default alignment to the dominant baseline positions the inline element for the superscript to the dominant baseline position in the shifted baseline-table of the parent element.
Reducing the font-size of the superscript automatically resets the baseline-table size so that mixed languages in the superscript stay mutually aligned.
In additions to the authors, this specification would not have been possible without the help from:
Stephen Deach, Sujal Parikh, Grzegorz Zygmunt, Chris Wilson, David M Brown.
New draft, but with a large piece taken out from former versions of CSS3 text and CSS2