Cascading Style Sheets, Level 2 Revision 1
Total Page:16
File Type:pdf, Size:1020Kb
Cascading Style Sheets, Level 2 revision 1 [p. ??] Cascading Style Sheets, level 2 revision 1 CSS 2.1 Specification W3C Working Draft 28 January 2003 This version: http://www.w3.org/TR/2003/WD-CSS21-20030128 [p. ??] Latest version: http://www.w3.org/TR/CSS21 [p. ??] Previous version: http://www.w3.org/TR/2002/WD-CSS21-20020802 [p. ??] Editors: Bert Bos [p. ??] <bert @w3.org> Tantek Çelik [p. ??] <tantekc @microsoft.com> Ian Hickson [p. ??] <ian @hixie.ch> Håkon Wium Lie [p. ??] <howcome @opera.com> This document is also available in these non-normative formats: plain text [p. ??] , gzip’ed tar file [p. ??] , zip file [p. ??] , gzip’ed PostScript [p. ??] , PDF [p. ??] . See also translations [p. ??] . Copyright [p. ??] © 2003 W3C [p. ??] ® (MIT [p. ??] , European Research Consor- tium for Informatics and MathematicsERCIM [p. ??] , Keio [p. ??] ), All Rights Reserved. W3C liability [p. ??] , trademark [p. ??] , document use [p. ??] and soft- ware licensing [p. ??] rules apply. Abstract This specification defines Cascading Style Sheets, level 2 revision 1 (CSS 2.1). CSS 2.1 is a style sheet language that allows authors and users to attach style (e.g., fonts, spacing, and aural cues) to structured documents (e.g., HTML documents and XML applications). By separating the presentation style of documents from the content of documents, CSS 2.1 simplifies Web authoring and site maintenance. CSS 2.1 builds on CSS2 [CSS2] which builds on CSS1 [CSS1]. It supports media-specific style sheets so that authors may tailor the presentation of their docu- ments to visual browsers, aural devices, printers, braille devices, handheld devices, etc. It also supports content positioning, table layout, features for internationalization and some properties related to user interface. 1 27 Jan 2003 17:36 Cascading Style Sheets, Level 2 revision 1 CSS 2.1 corrects a few errors in CSS2 (the most important being a new definition of the height/width of absolutely positioned elements, more influence for HTML’s "style" attribute and a new calculation of the ’clip’ property). CSS 2.1 corrects a few errors in CSS2 (the most important being a new definition of the height/width of absolutely positioned elements, more influence for HTML’s "style" attribute and a new calculation of the ’clip’ property), and adds a few highly requested features which have already been widely implemented. But most of all CSS 2.1 represents a "snapshot" of CSS usage: it consists of all CSS features that were implemented interoperably at the date of publication. Status of this document This document is produced by the CSS working group [p. ??] (part of the Style Activ- ity [p. ??] , see summary [p. ??] ). The CSS WG is aware that this draft does not yet address all the comments raised on the previous draft. The next draft should follow in a few weeks and is expected to be the final one. The (archived [p. ??] ) public mailing list [email protected] [p. ??] (see instruc- tions [p. ??] ) is preferred for discussion of this and other drafts in the Style area. When commenting on this draft, please put the text "CSS21" in the subject, prefer- ably like this: "[CSS21] <summary of comment>" For this specification to exit the CR stage, the following conditions shall be met: 1. There must be at least two interoperable implementations implementing ’all’ the features. An implementation can implement a superset of the features and claim conformance to the profile. For the purposes of this criterion, we define the following terms: feature An individual test case in the test suite. interoperable passing the respective test case(s) in the CSS test suite, or, if the imple- mentation is not a web browser, an equivalent test. Every relevant test in the test suite should have an equivalent test created if such a UA is to be used to claim interoperability. In addition if such a UA is to be used to claim interoperability, then there must one or more additional UAs which can also pass those equivalent tests in the same way for the purpose of interoper- ability. The equivalent tests must be made publicly available for the purposes of peer review. implementation a user agent which: 1. implements the feature. 2. is available (i.e. publicly downloadable or available through some other public point of sale mechanism). This is the "show me" requirement. 27 Jan 2003 17:36 2 Cascading Style Sheets, Level 2 revision 1 3. is shipping (i.e. development, private or unofficial versions are insuffi- cient). 4. is not experimental (i.e. is intended for a wide audience and could be used on a daily basis.) 2. A minimum of sixth months of the CR period must have elapsed. This is to ensure that enough time is given for any remaining major errors to be caught. 3. Features may/will be dropped if two or more interoperable implementations are not found by the end of the CR period. 4. Features may/will also be dropped if adequate/sufficient (by judgment of CSS WG) tests have not been produced for those feature(s) by the end of the CR period. This is a public W3C Working Draft for review by W3C Members and other inter- ested parties. It is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as refer- ence material or to cite them as other than "work in progress." Patent disclosures relevant to CSS may be found on the Working Group’s public patent disclosure page. [p. ??] A list of current W3C Recommendations and other technical documents can be found at http://www.w3.org/TR [p. ??] . 3 27 Jan 2003 17:36 Cascading Style Sheets, Level 2 revision 1 Quick Table of Contents 1 About the CSS 2.1 Specification . 15. 2 Introduction to CSS 2.1 . 23. 3 Conformance: Requirements and Recommendations . 31. 4 Syntax and basic data types . 37. 5 Selectors . 57. 6 Assigning property values, Cascading, and Inheritance . 77. 7 Media types . 85. 8 Box model . 89. 9 Visual formatting model . 105. 10 Visual formatting model details . 145. 11 Visual effects . 163. 12 Generated content, automatic numbering, and lists . 171. 13 Paged media . 189. 14 Colors and Backgrounds . 199. 15 Fonts . 207. 16 Text . 219. 17 Tables . 227. 18 User interface . 251. Appendix A. Aural style sheets . 259. Appendix B. Bibliography . 307. Appendix C. Changes . 281. Appendix D. A sample style sheet for HTML 4.0 . 279. Appendix E. Property index . 311. Appendix F. Index . 319. Appendix G. Grammar of CSS 2.1 . 301. 27 Jan 2003 17:36 4 Cascading Style Sheets, Level 2 revision 1 Full Table of Contents 1 About the CSS 2.1 Specification . 15. 1.1 CSS 2.1 vs CSS 2 . 15. 1.2 Reading the specification . 16. 1.3 How the specification is organized . 16. 1.4 Conventions . 17. 1.4.1 Document language elements and attributes . 17. 1.4.2 CSS property definitions . 17. Value . 17. Initial . 18. Applies to . 19. Inherited . 19. Percentage values . 19. Media groups . 19. Computed value . 19. 1.4.3 Shorthand properties . 19. 1.4.4 Notes and examples . 20. 1.4.5 Images and long descriptions . 20. 1.5 Acknowledgments . 20. 1.6 Copyright Notice . 20. 2 Introduction to CSS 2.1 . 23. 2.1 A brief CSS 2.1 tutorial for HTML . 23. 2.2 A brief CSS 2.1 tutorial for XML . 26. 2.3 The CSS 2.1 processing model . 27. 2.3.1 The canvas . 28. 2.3.2 CSS 2.1 addressing model . 28. 2.4 CSS design principles . 29. 3 Conformance: Requirements and Recommendations . 31. 3.1 Definitions . 31. 3.2 Conformance . 34. 3.3 Error conditions . 35. 3.4 The text/css content type . 35. 4 Syntax and basic data types . 37. 4.1 Syntax . 37. 4.1.1 Tokenization . 37. 4.1.2 Keywords . 40. 4.1.3 Characters and case . 40. 4.1.4 Statements . 41. 4.1.5 At-rules . 41. 4.1.6 Blocks . 42. 4.1.7 Rule sets, declaration blocks, and selectors . 42. 4.1.8 Declarations and properties . 43. 5 27 Jan 2003 17:36 Cascading Style Sheets, Level 2 revision 1 4.1.9 Comments . 44. 4.2 Rules for handling parsing errors . 44. 4.3 Values . 45. 4.3.1 Integers and real numbers . 46. 4.3.2 Lengths . 46. 4.3.3 Percentages . 49. 4.3.4 URL + URN = URI . 49. 4.3.5 Counters . 50. 4.3.6 Colors . 51. 4.3.7 Strings . 52. 4.3.8 Unsupported Values . 53. 4.4 CSS document representation . 53. 4.4.1 Referring to characters not represented in a character encoding54 5 Selectors . 57. 5.1 Pattern matching . 57. 5.2 Selector syntax . 59. 5.2.1 Grouping . 59. 5.3 Universal selector . 60. 5.4 Type selectors . 60. 5.5 Descendant selectors . 60. 5.6 Child selectors . 61. 5.7 Adjacent sibling selectors . 61. 5.8 Attribute selectors . 62. 5.8.1 Matching attributes and attribute values . 62. 5.8.2 Default attribute values in DTDs . 64. 5.8.3 Class selectors . 64. 5.9 ID selectors . 65. 5.10 Pseudo-elements and pseudo-classes . 67. 5.11 Pseudo-classes . 67. 5.11.1 :first-child pseudo-class . 68. 5.11.2 The link pseudo-classes: :link and :visited . 68. 5.11.3 The dynamic pseudo-classes: :hover, :active, and :focus . 69. 5.11.4 The language pseudo-class: :lang . 70. 5.12 Pseudo-elements . 71. 5.12.1 The :first-line pseudo-element . 71. 5.12.2 The :first-letter pseudo-element . 72. 5.12.3 The :before and :after pseudo-elements .