The key points of CSS syntax are as follows:
- Unicode UTF-8 should be used to encode CSS Files - the same way you should encode HTML files.
- CSS code should be lowercase. Selectors are case sensitives when referencing element names, classes, attributes, and IDs in XHTML. CSS properties and values are case insensitive.
- Element names, classes, and IDs are restricted to letters, numbers, underscores (_), hyphens(-), and Unicode characters 161 and higher. The first character of an element, class, or ID must not be a number or a hyphen. A classname and ID must not contain punctuation other than the underscore and hyphen.
- Mulitple classes can be assigned to an element by separating each class name with a space, such as class="class1 class2 class3".
- Constant values should not be placed in quotes. For example, color:black; is correct, but color:"black"; is not.
- The backslash (\) can be used to embed characters in a context where they normally cannot occur; for example, \26b embeds & in a string or identifier. Anywhere from two to eight hex codes can follow a backslash, or a character can follow a backslash.
- A string may contain parentheses, commas, whitespace, single quotes ('), and double quotes (") as long as they are escaped with a backslash.
- A semicolon should terminate each CSS rule and @import statement.
- Rulesets are created by enclosing multiple rules in curly braces.
- A CSS comment starts with /* and ends with */. Comments cannot be nested. Thus, the first time a browser encounters */ in a stylesheet, it terminates the comment.
|
|