HTML and CSS Reference
should not use green but instead ignore the whole rule. Of course, what browser vendors
actually do in the face of malformed Web documents varies.
Incorrect @ Keywords and Media Values
When an @ media value or media type for a <style> tag is used, incorrect values should be
ignored. For example, if you specify <style type= " text/css " media= " tri-corder " > ,
the browser is supposed to ignore the entire <style> block unless it understands such an
odd type. Media types will be discussed in depth later, but for now understand that when
faced with syntax problems, a CSS-compliant browser should simply ignore anything
related to misunderstood values.
Ignoring Network Failures
When style sheets are linked rather than placed within the page, the browser must apply all
types it is able to fetch and simply ignore those it can't. So if you had
<link rel="stylesheet" href="global.css" type="text/css">
<link rel="stylesheet" href="pagelevel.css" type="text/css">
and the first was fetched by the browser, but the second failed, it would simply apply the
rules it had. Obviously, such transitory errors are hard to account for, but other
considerations presented in this section should have been caught in the validation of
markup and style, discussed next.
Like (X)HTML, it is quite possible to check your style usage against the specification.
This is also called “validation,” though the term “conformance checking” may be more
appropriate, but the intent is still clear. The W3C provides a validation service for CSS at
http://jigsaw.w3.org/css-validator/. As an example, validating the page found at www
.htmlref.com/ch4/hellomalformedcssworld.html shows that it contains a number of simple
errors, as shown here:
Bad property name and value
Bad property value
Missing } to
The previous section identifies what a conformant browser should do with such errors
and, interestingly, the result is that the malformed page should appear the same as the
“well-formed page.” Like HTML, we often won't pay a price for our mistakes until later.
The good news is that we can easily uncover these types of errors, as shown in Figure 4-6.
Notice that the service shows what is considered the resulting style sheet in light of the