HTML and CSS Reference
In-Depth Information
follows would then be used. Because the color property has an illegal value, it should be
Other cases are a bit more obvious. For example, here we see the colon missing in a style
rule declaration:
h1 {color red; text-decoration: underline; font-style: italic;}
In this case, the color property is simply ignored and the text is underlined and italic.
The situation for quotes and braces is the same, with compliant browsers working to
find a matching closing character for any open construct, potentially destroying anything in
between. Consider this set of rules, where quite a large amount of style may be lost:
h1 {color: green; font-family: "Super Font;}
h2 {color: orange;}
h3 {color: blue; font-family: "Duper Font";}
Be careful, though, because in this case you might assume that the rule closes off with a
quote, but that may introduce more open construct errors later on in the style sheet.
Unclosed Structures and End of File
A CSS browser should close all braces and quotes when it reaches the end of a style sheet.
While quite permissive, this would suggest that
<style type="text/css">
h1 {color: green
should render properly, as the open rule would be closed automatically by the end of the
style sheet. Open quotes would also be closed in a similar manner when the end of the style
sheet is reached. Testing reveals this action is actually the case in browsers, but creating a
syntactically correct style sheet is obviously far superior than understanding the expected
failures of a conformant browser.
Illegal or Unknown Property Values
CSS-conforming browsers must ignore a declaration with an illegal value. For example,
h1 {font-size: microscopic; color: red;}
would simply not set the font-size value but h1 elements would be red. Usage of illegal
characters can turn what would appear to be a correct value into an incorrect one. For
h1 {color: " green " ;}
is incorrect not because green is an illegal color, but because it is not the same as the
keyword green when it is quoted.
Do not assume that a CSS-compliant browser will fix such small oversights. For
example, a browser given
h1 {color: green forest;}
Search WWH ::

Custom Search