HTML and CSS Reference
In-Depth Information
Roughly, this says that a ruleset contains a selector of some sort, a curly left brace ( LBRACE ),
a declaration or a set of declarations followed by a semicolon, and then a closing right brace.
This basically defines the rule syntax we have seen earlier, repeated again here:
selector {property1 : value1; ... propertyN : valueN;}
Now if you continue to read the specification, you can see that selectors are then defined by
: simple_selector [ combinator simple_selector ]*
which in turn references a simple_selector , which would include some of the types of
selectors like element names, class , and id values we have seen earlier. The production
rule of CSS grammar here shows just that:
: element_name [ HASH | class | attrib | pseudo ]*
| [ HASH | class | attrib | pseudo ]+
Yet as you expand the grammar, you should see what appears to be ambiguity. For
example, when you expand to an element_name , it will indicate that a wildcard value of
* ” can be used to match an element and then simply a value of IDENT , shown here:
: IDENT | '*'
IDENT will resolve to another part of the specification that defines a valid token that is a
fairly large range of strings. Simply put, the element_name selector can be just about
anything, which makes perfect sense because CSS can be used for not just HTML but also
for arbitrary XML languages, which could have a variety of possible tags. Given the wide
possibility of usage for CSS, this ambiguity is somewhat to be expected, but even the
various property names and values are not directly spelled out in the grammar and are left
to the prose of the specification. In fact, the forward-looking nature of the CSS specification
gives some latitude here in terms of such values instead of specifying the rules for what a
browser should do when faced with properties or values it doesn't understand, as discussed
in the next section.
The various aspects of the CSS grammar that are a bit ambiguous are so not because of
some oversight but due to the intersection between CSS and other technologies. For example,
consider the situation of case sensitivity, as previously discussed in the chapter. CSS property
names and many values will be case insensitive, so font-size and FONT-SIZE are both
okay as are declarations like font-size: RED and font-size: red . Even selectors may
not be case sensitive; for example,
H1 {color: red;}
should be the same as
h1 {color: red;}
Search WWH ::

Custom Search