Alignment: the ‘text-align’ property
0- ‘text-align’
- Value: left | right | center | justify | | inherit Initial: depends on user agent and writing direction Applies to: block-level elements Inherited: yes Percentages: N/A Media: visual
This property describes how inline content of a block is aligned. Values have the following meanings:
- left, right, center, and justify
- Left, right, center, and double justify text, respectively.
- “>
- Specifies a string on which cells in a table column will align (see the section on horizontal alignment in a column for details and an example). This value applies only to table cells. If set on other elements, it will be treated as ‘left’ or ‘right’, depending on whether ‘direction’ is ‘ltr’, or ‘rtl’, respectively.
Semantic changes from CSS1
0While all CSS1 style sheets are valid CSS2 style sheets, there are a few cases where the CSS1 style sheet will have a different meaning when interpreted as a CSS2 style sheet. Most changes are due to implementation experience feeding back into the specification, but there are also some error corrections.
- The meaning of “!important” has been changed. In CSS1, “!important” in an author’s style sheet took precedence over one in a user style sheet. This has been reversed in CSS2.
- In CSS2 color values are clipped with regard to the device gamut, not with regard to the sRGB gamut as in CSS1.
- CSS1 simply said that ‘margin-right’ was ignored if the both ‘margin-left’ and ‘width’ were set. In CSS2 the choice between relaxing ‘margin-right’ or ‘margin-left’ depends on the writing direction.
- In CSS1, several properties (e.g., ‘padding’) had values referring to the width
CSS3 New functionality
0In addition to the functionality of CSS1, CSS2 supports:
- The concept of media types.
- The ‘inherit’ value for all properties.
- Paged media
- Aural style sheets
- Several internationalization features, including list numbering styles, support for bidirectional text, and support for language-sensitive quotation marks.
- An extended font selection mechanism, including intelligent matching, synthesis, and downloadable fonts. Also, the concept of system fonts has been is introduced, and a new property, ‘font-size-adjust’, has been added.
- Tables, including new values on ‘display’ and ‘vertical-align’.
- Relative and absolute positioning, including fixed positioning.
- New box types (along with block and inline): compact and run-in.
- The ability to control content overflow, clipping, and visibility in the visual formatting model.
- The ability to specify minimum and maximum widths
Comparison of tokenization in CSS2 and CSS1
0There are some differences in the syntax specified in the CSS1 recommendation ([CSS1]), and the one above. Most of these are due to new tokens in CSS2 that didn’t exist in CSS1. Others are because the grammar has been rewritten to be more readable. However, there are some incompatible changes, that were felt to be errors in the CSS1 syntax. They are explained below.
- CSS1 style sheets could only be in 1-byte-per-character encodings, such as ASCII and ISO-8859-1. CSS2 has no such limitation. In practice, there was little difficulty in extrapolating the CSS1 tokenizer, and some UAs have accepted 2-byte encodings.
- CSS1 only allowed four hex-digits after the backslash (\) to refer to Unicode characters, CSS2 allows six. Furthermore, CSS2 allows a whitespace character to delimit the escape sequence. E.g., according to CSS1, the string “\abcdef” has 3 letters (\abcd, e, and f), according to CSS2
CSS3 Lexical scanner
0The following is the tokenizer, written in Flex (see [FLEX]) notation. The tokenizer is case-insensitive.
The two occurrences of “\377″ represent the highest character number that current versions of Flex can deal with (decimal 255). They should be read as “\4177777″ (decimal 1114111), which is the highest possible code point in Unicode/ISO-10646.
%option case-insensitive
h [0-9a-f]nonascii [\200-\377]unicode \\{h}{1,6}[ \t\r\n\f]?escape {unicode}|\\[ -~\200-\377]nmstart [a-z]|{nonascii}|{escape}nmchar [a-z0-9-]|{nonascii}|{escape}string1 \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"string2 \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
ident {nmstart}{nmchar}*name {nmchar}+num [0-9]+|[0-9]*"."[0-9]+string {string1}|{string2}url ([!#$%&*-~]|{nonascii}|{escape})*w [ \t\r\n\f]*nl \n|\r\n|\r|\frange \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
%%
[ \t\r\n\f]+ {return S;}
\/\*[^*]*\*+([^/][^*]*\*+)*\/ /* ignore comments */
"" {return CDC;}"~=" {return INCLUDES;}"|=" {return DASHMATCH;}
{string} {return STRING;}
{ident} {return IDENT;}
"#"{name} {return HASH;}
"@import" {return IMPORT_SYM;}"@page" {return PAGE_SYM;}"@media" {return MEDIA_SYM;}"@font-face" {return FONT_FACE_SYM;}"@charset" {return CHARSET_SYM;}"@"{ident} {return ATKEYWORD;}
"!{w}important" {return IMPORTANT_SYM;}
{num}em {return EMS;}{num}ex {return EXS;}{num}px {return LENGTH;}{num}cm {return LENGTH;}{num}mm {return LENGTH;}{num}in {return LENGTH;}{num}pt {return LENGTH;}{num}pc {return LENGTH;}{num}deg {return ANGLE;}{num}rad {return ANGLE;}{num}grad {return ANGLE;}{num}ms {return CSS3 Grammar
0The grammar below is LL(1) (but note that most UA’s should not use it directly, since it doesn’t express the parsing conventions, only the CSS2 syntax). The format of the productions is optimized for human consumption and some shorthand notation beyond Yacc (see [YACC]) is used:
- *: 0 or more
- +: 1 or more
- ?: 0 or 1
- |: separates alternatives
- [ ]: grouping
The productions are:
stylesheet : [ CHARSET_SYM S* STRING S* ';' ]? [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* [ [ ruleset | media | page | font_face ] [S|CDO|CDC]* ]* ;import : IMPORT_SYM S* [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S* ;media : MEDIA_SYM S* medium [ ',' S* medium ]* '{' S* ruleset* '}' S* ;medium : IDENT S* ;page : PAGE_SYM S* IDENT? pseudo_page? S* '{' S* declaration Visibility: the ‘visibility’ property
0- ‘visibility’
- Value: visible | hidden | collapse | inherit Initial: inherit Applies to: all elements Inherited: no Percentages: N/A Media: visual
The ‘visibility’ property specifies whether the boxes generated by an element are rendered. Invisible boxes still affect layout (set the ‘display’ property to ‘none’ to suppress box generation altogether). Values have the following meanings:
- visible
- The generated box is visible.
- hidden
- The generated box is invisible (fully transparent), but still affects layout.
- collapse
- Please consult the section on dynamic row and column effects in tables. If used on elements other than rows or columns, ‘collapse’ has the same meaning as ‘hidden’.
This property may be used in conjunction with scripts to create dynamic effects.
In the following example, pressing either form
Recognized media types
0A CSS media type names a set of CSS properties. A user agent that claims to support a media type by name must implement all of the properties that apply to that media type.
The names chosen for CSS media types reflect target devices for which the relevant properties make sense. In the following list of CSS media types, the parenthetical descriptions are not normative. They only give a sense of what device the media type is meant to refer to.
- all
- Suitable for all devices.
- aural
- Intended for speech synthesizers. See the section on aural style sheets for details.
- braille
- Intended for braille tactile feedback devices.
- embossed
- Intended for paged braille printers.
- handheld
- Intended for handheld devices (typically small screen, monochrome, limited bandwidth).
- Intended for paged, opaque material and for documents viewed
