Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification
Total Page:16
File Type:pdf, Size:1020Kb
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification W3C Recommendation 07 June 2011, edited in place 12 April 2016 to point to new work This version: http://www.w3.org/TR/2011/REC-CSS2-20110607 Latest version: http://www.w3.org/TR/CSS2 Previous versions: http://www.w3.org/TR/2011/PR-CSS2-20110412 http://www.w3.org/TR/2008/REC-CSS2-20080411/ Latest editor's draft: http://dev.w3.org/csswg/css2/ Editors: Bert Bos <BERT @w3.org> Tantek Çelik <TANTEK @cs.stanford.edu> Ian Hickson <IAN @hixie.ch> Håkon Wium Lie <HOWCOME @opera.com> Please refer to the errata for this document. This document is also available in these non-normative formats: plain text, gzip'ed tar file, zip file, gzip'ed PostScript, PDF. See also translations. Copyright © 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C LIABILITY, TRADEMARK AND DOCUMENT USE 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 and spac- ing) 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] p. 284 which builds on CSS1 [CSS1] p. 283. It supports media-specific style sheets so that authors may tailor the presentation of their documents to visual browsers, aural devices, printers, braille devices, handheld devices, etc. It also sup- ports content positioning, table layout, features for internationalization and some properties related to user interface. – 1 – – Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification – 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 are implemented interoperably at the date of publication of the Recommendation. CSS 2.1 is derived from and is intended to replace CSS2. Some parts of CSS2 are un- changed in CSS 2.1, some parts have been altered, and some parts removed. The re- moved portions may be used in a future CSS3 specification. Future specs should refer to CSS 2.1 (unless they need features from CSS2 which have been dropped in CSS 2.1, and then they should only reference CSS2 for those features, or preferably reference such fea- ture(s) in the respective CSS3 Module that includes those feature(s)). Status of this document This section describes the status of this document at the time of its publication. Other docu- ments may supersede this document. A list of current W3C publications and the latest revi- sion of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/. This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Rec- ommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. The (ARCHIVED) public mailing list [email protected] (see INSTRUCTIONS) is preferred for discussion of this specification. When sending e-mail, please put the text “CSS21” in the subject, preferably like this: “[CSS21] …summary of comment…” This document was produced by the CSS Working Group (part of the Style Activity). This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes CONTAINS Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy. The Working Group has created a test suite and an implementation report. All changes since the previous Working Draft, the previous Candidate Recommendation and the previous Recommendation are listed in APPENDIX C. p. 286 Note: Several sections of this specification have been updated by other speci- fications. Please, see "Cascading Style Sheets (CSS) — The Official Definition" in the latest CSS Snapshot for a list of specifications and the sections they re- place. The CSS Working Group is also developing CSS level 2 revision 2 (CSS 2.2). – 2 – – Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification – Quick Table of Contents 1 About the CSS 2.1 Specification . 23 2 Introduction to CSS 2.1 . 30 3 Conformance: Requirements and Recommendations . 38 4 Syntax and basic data types . 44 5 Selectors . 67 6 Assigning property values, Cascading, and Inheritance . 87 7 Media types . 94 8 Box model . 98 9 Visual formatting model . 112 10 Visual formatting model details. 152 11 Visual effects. 172 12 Generated content, automatic numbering, and lists . 180 13 Paged media . 196 14 Colors and Backgrounds . 204 15 Fonts . 211 16 Text. 224 17 Tables. 233 18 User interface . 258 Appendix A. Aural style sheets . 264 Appendix B. Bibliography . 282 Appendix C. Changes . 286 Appendix D. Default style sheet for HTML 4 . 402 Appendix E. Elaborate description of Stacking Contexts . 404 Appendix F. Full property table . 408 Appendix G. Grammar of CSS 2.1 . 420 Appendix I. Index . 426 Full Table of Contents 1 About the CSS 2.1 Specification . 23 1.1 CSS 2.1 vs CSS 2 . 23 1.2 Reading the specification. 24 1.3 How the specification is organized. 24 1.4 Conventions . 25 1.4.1 Document language elements and attributes . 25 1.4.2 CSS property definitions . 25 1.4.2.1 Value . 25 1.4.2.2 Initial . 27 1.4.2.3 Applies to . 27 1.4.2.4 Inherited . 27 1.4.2.5 Percentage values . 27 1.4.2.6 Media groups . 27 1.4.2.7 Computed value . 27 1.4.3 Shorthand properties. 27 – 3 – – Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification – 1.4.4 Notes and examples . 28 1.4.5 Images and long descriptions . 28 1.5 Acknowledgments . 28 2 Introduction to CSS 2.1 . 30 2.1 A brief CSS 2.1 tutorial for HTML . 30 2.2 A brief CSS 2.1 tutorial for XML. 32 2.3 The CSS 2.1 processing model . 34 2.3.1 The canvas . 35 2.3.2 CSS 2.1 addressing model . 35 2.4 CSS design principles . 35 3 Conformance: Requirements and Recommendations . 38 3.1 Definitions . 38 3.2 UA Conformance . 42 3.3 Error conditions . ..