|
1 | 1 | <!DOCTYPE HTML SYSTEM "http://www.w3.org/TR/WD-html40/sgml/HTML4.dtd"> |
2 | 2 | <html lang="en"> |
3 | | -<!-- $Id: conform.src,v 1.3 1997-08-05 17:31:02 ijacobs Exp $ --> |
| 3 | +<!-- $Id: conform.src,v 1.4 1997-08-11 23:53:15 ian Exp $ --> |
4 | 4 | <HEAD> |
5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
6 | 6 | <TITLE>CSS2 Conformance</TITLE> |
|
10 | 10 | </HEAD> |
11 | 11 | <BODY> |
12 | 12 | <H1 align="center">CSS2 Conformance</H1> |
13 | | -<!-- Core conformance? All CSS1 stuff is *required* for conformance |
14 | | -in CSS2 --> |
| 13 | +<P><em> This section only defines conformance to CSS2. There will be other |
| 14 | +levels of CSS in the future that may require a UA to implement a |
| 15 | +different set of features in order to conform.</em> |
| 16 | + |
| 17 | + |
| 18 | +<P> A User Agent that uses CSS2 <strong>to display</strong> documents |
| 19 | +conforms to the CSS2 specification if it: |
| 20 | + <UL> |
| 21 | + <LI> attempts to fetch all referenced style sheets and parse them |
| 22 | + according to this specification |
| 23 | + |
| 24 | + <LI> sorts the declarations according to the <a |
| 25 | + href="./cascade.html#cascade-order">cascade order</a>. |
| 26 | + |
| 27 | + <LI> implements the CSS2 functionality within the <a |
| 28 | + href="#presentation-constraints">constraints of the presentation |
| 29 | + medium</a> (see explanation below). |
| 30 | + |
| 31 | + <LI> implements all of CSS1, not just the core sections. |
| 32 | + </UL> |
| 33 | + |
| 34 | +<P> A User Agent that <strong>outputs</strong> CSS2 style sheets |
| 35 | +conforms to the CSS2 specification if it: |
| 36 | + |
| 37 | + <UL> |
| 38 | + <LI> |
| 39 | + outputs valid CSS2 style sheets |
| 40 | + </UL> |
| 41 | + |
| 42 | +<P> A User Agent that uses CSS2 to display documents <EM>and</EM> |
| 43 | +outputs CSS2 style sheets conforms to the CSS2 specification if it |
| 44 | +meets both sets of conformance requirements. |
| 45 | + |
| 46 | +A UA does not have to implement all the functionality of CSS2: it can |
| 47 | +conform to CSS2 by implementing the <a |
| 48 | +href="convent.html#definitions">core functionality</a>. |
| 49 | + |
| 50 | +<P> This specification also recommends, but doesn't require, that a |
| 51 | +UA: |
| 52 | + |
| 53 | + <UL> |
| 54 | + <LI> allows the reader to specify personal style sheets |
| 55 | + <LI> allows individual style sheets to be turned on and off |
| 56 | + </UL> |
| 57 | + |
| 58 | +<P> The above conformance rules describe only functionality, not user |
| 59 | + interface. |
| 60 | + |
| 61 | +<H2><a name="presentation-constraints">Conformance constraints due to presentation medium</a></H2> |
| 62 | +<P> Examples of constraints of the presentation medium are: limited |
| 63 | +resources (fonts, color) and limited resolution (so margins may not be |
| 64 | +accurate). In these cases, the UA should approximate the style sheet |
| 65 | +values. Also, different user interface paradigms may have their own |
| 66 | +constraints: a VR browser may rescale the document based on its |
| 67 | +"distance" from the user. |
| 68 | + |
| 69 | +<P> UAs may offer readers additional choices on presentation. For |
| 70 | +example, the UA may provide options for readers with visual |
| 71 | +impairments or may provide the choice to disable blinking. |
| 72 | + |
| 73 | +<P> Note that CSS2 does not specify all aspects of formatting, e.g., |
| 74 | +the UA is free to select a letter-spacing algorithm. |
| 75 | + |
| 76 | + |
| 77 | +<H2><A NAME="forward-compatible-parsing">Forward-compatible parsing</A></H2> |
| 78 | +<em>See <a href="grammar.html">Appendix B</a> for the grammar of CSS2</em> |
| 79 | + |
| 80 | +<P> To ensure that UAs supporting just CSS2 will be able to parse style |
| 81 | +sheets containing higher level features, this section defines what the |
| 82 | +UA must do when it encounters certain constructs that are not valid in |
| 83 | +CSS2 |
| 84 | + |
| 85 | +<UL> |
| 86 | + <LI> a declaration with an unknown property is ignored. For |
| 87 | + example, if the style sheet is |
| 88 | +<PRE> H1 { color: red; rotation: 70deg } |
| 89 | +</PRE> |
| 90 | + <P> the UA will treat this as if the style sheet had been |
| 91 | + |
| 92 | +<PRE> H1 { color: red; } |
| 93 | +</PRE> |
| 94 | + |
| 95 | + <LI> illegal values, <EM>or values with illegal parts</EM>, are |
| 96 | + treated as if the declaration weren't there at all: |
| 97 | + |
| 98 | +<PRE> |
| 99 | + IMG { float: left } /* CSS2 */ |
| 100 | + IMG { float: left top } /* "top" is not a value of 'float' */ |
| 101 | + IMG { background: "red" } /* keywords cannot be quoted in CSS2 */ |
| 102 | + IMG { border-width: 3 } /* a unit must be specified for length values */ |
| 103 | +</PRE> |
| 104 | + |
| 105 | +<P> In the above example, a CSS2 parser would honor the first rule and |
| 106 | +ignore the rest, as if the style sheet had been: |
| 107 | + |
| 108 | +<PRE> |
| 109 | + IMG { float: left } |
| 110 | + IMG { } |
| 111 | + IMG { } |
| 112 | + IMG { } |
| 113 | +</PRE> |
| 114 | + |
| 115 | +<P> A UA conforming to a future CSS specification may accept one or |
| 116 | +more of the other rules as well. |
| 117 | + |
| 118 | +<LI> an invalid at-keyword is ignored together with everything |
| 119 | +following it, up to and including the next semicolon (;) or brace pair |
| 120 | +({...}), whichever comes first. For example, assume the style sheet |
| 121 | +reads: |
| 122 | + |
| 123 | +<PRE> |
| 124 | + @three-dee { |
| 125 | + @background-lighting { |
| 126 | + azimuth: 30deg; |
| 127 | + elevation: 190deg; |
| 128 | + } |
| 129 | + H1 { color: red } |
| 130 | + } |
| 131 | + H1 {color: blue} |
| 132 | +</PRE> |
| 133 | + |
| 134 | +<P> The '@three-dee' is illegal according to CSS2. Therefore, the |
| 135 | +whole at-rule (up to, and including, the third right curly brace) is |
| 136 | +ignored. The CSS2 UA skips it, effectively reducing the style sheet |
| 137 | +to: |
| 138 | + |
| 139 | +<PRE> |
| 140 | + H1 {color: blue} |
| 141 | +</PRE> |
| 142 | +/UL> |
| 143 | + |
| 144 | +<H3>Statements</H3> |
| 145 | +<P> A CSS style sheet, for any version of CSS, consists of a list of |
| 146 | +<span class="index-inst" title="statements"><em>statements</em></span>. |
| 147 | +There are two kinds of statements: <span class="index-inst" |
| 148 | +title="at-rules|@-rules"><em>at-rules</em></span> and <span |
| 149 | +class="index-inst" title="rule sets"><em>rule sets</em> </span>. There |
| 150 | +may be whitespace (spaces, tabs, newlines) around the statements. |
| 151 | + |
| 152 | +<H3>At-rules</H3> |
| 153 | +<P> At-rules start with an <DFN>at-keyword</DFN>, which is an |
| 154 | +identifier with an '@' at the start (for example, '@import', '@page', |
| 155 | +etc.). An identifier consists of letters, digits, dashes and escaped |
| 156 | +characters (defined below). |
| 157 | + |
| 158 | +<P> An at-rule consists of everything up to and including the next |
| 159 | +semicolon (;) or the next block (defined shortly), whichever comes |
| 160 | +first. A CSS2 UA that encounters an at-rule that starts with an |
| 161 | +at-keyword other than '@import' ignores the whole of the at-rule and |
| 162 | +continue parsing after it. It also ignores any at-rule that starts |
| 163 | +with '@import' if it doesn't occur at the top of the style sheet, |
| 164 | +i.e., if it occurs after any rules (even ignored rules). |
| 165 | + |
| 166 | +<div class="example"><P> |
| 167 | +Here is an example. Assume a CSS2 parser encounters this style sheet: |
| 168 | + |
| 169 | +<PRE> |
| 170 | + @import "subs.css"; |
| 171 | + H1 { color: blue } |
| 172 | + @import "list.css"; |
| 173 | +</PRE> |
| 174 | + |
| 175 | +<P> The second '@import' is illegal according to CSS2. The CSS2 parser |
| 176 | +skips the whole at-rule, effectively reducing the style sheet to: |
| 177 | + |
| 178 | +<PRE> |
| 179 | + @import "subs.css"; |
| 180 | + H1 {color: blue} |
| 181 | +</PRE> |
| 182 | +</div> |
| 183 | + |
| 184 | +<H3>Blocks</H3> |
| 185 | +<P> A <span class="index-inst" |
| 186 | +title="block"><em>block</em></span> starts with a left curly brace ({) |
| 187 | +and ends with the matching right curly brace (}). In between there may |
| 188 | +be any characters, except that parentheses (()), brackets ([]) and |
| 189 | +braces ({}) always occur in matching pairs and may be nested. Single |
| 190 | +(') and double quotes (") <!-- " --> also occur in matching pairs, and |
| 191 | +characters between them are parsed as a <span class="index-inst" |
| 192 | +title="string">string</span>. See the tokenizer in <a |
| 193 | +href="grammar.html">Appendix B</a> for the definition of a string. |
| 194 | + |
| 195 | +<div class="example"><P> |
| 196 | +Here is an example of a block. Note that the right brace between the quotes |
| 197 | +does not match the opening brace of the block, and that the second |
| 198 | +single quote is an escaped character, and thus doesn't match the |
| 199 | +opening quote: |
| 200 | + |
| 201 | +<PRE> |
| 202 | + { causta: "}" + ({7} * '\'') } |
| 203 | +</PRE> |
| 204 | +</div> |
| 205 | + |
| 206 | +<H3>Rule sets</H3> |
| 207 | + |
| 208 | +<P> A rule set consists of a <span class="index-inst" title="selector |
| 209 | +string"><em>selector string</em></span> followed by a <span |
| 210 | +class="index-inst" title="declaration block"><em>declaration |
| 211 | +block</em></span>. The selector-string consists of everything up to |
| 212 | +(but not including) the first left curly brace ({). A ruleset that |
| 213 | +starts with a selector-string that is not valid CSS2 is skipped. |
| 214 | + |
| 215 | +<div class="example"><P> |
| 216 | +For example, assume a CSS2 parser encounters this style sheet: |
| 217 | +<PRE> |
| 218 | + H1 { color: blue } |
| 219 | + P[align], UL { color: red; font-size: large } |
| 220 | + P EM { font-weight: bold } |
| 221 | +</PRE> |
| 222 | + |
| 223 | +<P> The second line contains a selector-string that is illegal in |
| 224 | +CSS2. The CSS2 UA will skip the ruleset, reducing the style sheet to: |
| 225 | + |
| 226 | +<PRE> |
| 227 | + H1 { color: blue } |
| 228 | + P EM { font-weight: bold } |
| 229 | +</PRE> |
| 230 | + |
| 231 | +<P> A declaration-block starts with a left curly brace ({) and ends |
| 232 | +with the matching right curly brace (}). In between there is a list of |
| 233 | +zero or more <DFN>declarations,</DFN> separated by semicolons (;). |
| 234 | + |
| 235 | +<H3>Properties</H3> |
| 236 | + |
| 237 | +<P> A declaration consists of a <span class="index-inst" |
| 238 | +title="property"><em>property</em></span>, a colon (:) and a |
| 239 | +<DFN>value</DFN>. Around each of these there may be whitespace. |
| 240 | + |
| 241 | +A property is an identifier, as defined earlier. Any character may |
| 242 | +occur in the value, but parentheses (()), brackets ([]), braces ({}), |
| 243 | +single quotes (') and double quotes (") |
| 244 | +<!-- " --> |
| 245 | +must come in matching pairs. Parentheses, brackets, and braces may be |
| 246 | +nested. Inside the quotes, characters are parsed as a string. |
| 247 | + |
| 248 | +<P> To ensure that new properties and new values for existing |
| 249 | +properties can be added in the future, a UA must skip a declaration |
| 250 | +with an invalid property name or an invalid value. Every CSS2 property |
| 251 | +has its own syntactic and semantic restrictions on the values it |
| 252 | +accepts. |
| 253 | + |
| 254 | +<div class="example"><P> |
| 255 | +For example, assume a CSS2 parser encounters this style sheet: |
| 256 | + |
| 257 | +<PRE> |
| 258 | + H1 { color: red; font-style: 12pt } |
| 259 | + P { color: blue; font-vendor: any; font-variant: small-caps } |
| 260 | + EM EM { font-style: normal } |
| 261 | +</PRE> |
| 262 | + |
| 263 | +<P> The second declaration on the first line has an invalid value |
| 264 | +'12pt'. The second declaration on the second line contains an |
| 265 | +undefined property 'font-vendor'. The CSS2 parser will skip these |
| 266 | +declarations, reducing the style sheet to: |
| 267 | + |
| 268 | +<PRE> |
| 269 | + H1 { color: red; } |
| 270 | + P { color: blue; font-variant: small-caps } |
| 271 | + EM EM { font-style: normal } |
| 272 | +</PRE> |
| 273 | +</div> |
| 274 | + |
| 275 | +<H3>Comments</H3> |
| 276 | + |
| 277 | +<P> <span class="index-inst" title="comments">Comments </span>(see the |
| 278 | +section on <a href="./syndata.html#comments">comments</a> for details) |
| 279 | +can occur anywhere where whitespace can occur and are considered to be |
| 280 | +whitespace. CSS2 defines additional places where whitespace can occur |
| 281 | +(such as inside values) and comments are allowed there as well. |
| 282 | + |
| 283 | +<H3>Characters and case</H3> |
| 284 | +<P> The following rules always hold: |
| 285 | + |
| 286 | +<UL> |
| 287 | + <LI> All CSS style sheets are <span class="index-inst" title="case |
| 288 | + sensitivity">case-insensitive</span>, except for parts that are |
| 289 | + not under the control of CSS. For example, the case-sensitivity of |
| 290 | + the HTML attributes 'id' and 'class', of font names, and of URLs |
| 291 | + lies outside the scope of this specification. |
| 292 | + |
| 293 | + <LI> In CSS2, selectors (element names, classes and IDs) can |
| 294 | + contain only the characters A-Z, 0-9, and <a rel="biblioentry" href="./refs.html#ref-UNICODE">[UNICODE]</a> characters |
| 295 | + 161-255, plus dash (-); they cannot start with a dash or a digit; |
| 296 | + they can also contain escaped characters and any Unicode character |
| 297 | + as a numeric code (see next item). |
| 298 | + |
| 299 | + <LI> the backslash followed by at most four hexadecimal digits |
| 300 | + (0..9A..F) stands for the <a rel="biblioentry" href="./refs.html#ref-UNICODE">[UNICODE]</a> character with that number. |
| 301 | + |
| 302 | + <LI> any character except a hexadecimal digit can be escaped to |
| 303 | + remove its special meaning, by putting a backslash in front, |
| 304 | + Example: "\"" is a string consisting of one double quote. |
| 305 | + |
| 306 | + <LI> the two preceding items define <span class="index-inst" title="backslash escapes"><EM>backslash-escapes</EM></span>. Backslash-escapes are always |
| 307 | + considered to be part of an identifier, except inside strings |
| 308 | + (i.e., "\7B" is not punctuation, even though "{" is, and "\32" is |
| 309 | + allowed at the start of a class name, even though "2" is not). |
| 310 | + </UL> |
| 311 | + |
| 312 | +<H2>CSS and HTML</H2> |
| 313 | + |
| 314 | +<P> CSS style sheets may be embedded in HTML documents, and to be able |
| 315 | +to hide style sheets from older UAs, it is convenient put the style |
| 316 | +sheets inside HTML comments. The HTML comment tokens "<!--" and |
| 317 | +"-->" may occur before, after, and in between the statements. They |
| 318 | +may have whitespace around them. |
| 319 | + |
| 320 | +<P> The "class" attribute of HTML allows more characters in a class |
| 321 | +name than the set allowed for selectors above. In CSS2, these |
| 322 | +characters have to be escaped or written as Unicode numbers: |
| 323 | +"B&W?" can be written as "B\&W\?" or "B\26W\3F", |
| 324 | +"º¿ÅÁ¿Â" (Greek: "kouros") has to be written as |
| 325 | +"\3BA\3BF\3C5\3C1\3BF\3C2". It is expected that in later versions of |
| 326 | +CSS, more characters can be entered directly. |
| 327 | + |
15 | 328 | </BODY> |
16 | 329 | </HTML> |
0 commit comments