CSS 2.1: Section 4

Back to CSS Test

Syntax and basic data types

This page contains some tests on section 4 of the CSS 2.1 specs. As this page includes much of test code, the embedded CSS won't validate.

4.1.1 Tokenization: whitespace

The following data types can occur in whitespace (token S):

Name Unicode
space 0020
tab 0009
line feed 000A
carriage return 000D
form feed 000C

The following data types are never part of whitespace:

Name Unicode
em space 2003
ideographic space 3000
declaration : DELIM? property S* ':' S* value;

Test

This paragraph should not be green.

This paragraph should not be red.

 p#green1 {color:'\0020'green;}
 p#red1 {color:\0020 red;}

Comments on test # 1

All browser ignore the declarations after the insertion of Unicode code.

4.1.7 Rule sets, declaration blocks, and selectors

Test

This paragraph should be red.

 p[title="public class foo\
	  {\
	    private int x;\
		\
		 foo (int x) {\
		 this.x = x;\
		 }\
	  \
	  }"] {color: red}

Comments on test # 2

Standard compliant browsers, which support the attribute selector, do not apply the declaration.

4.2 Rules for handling parsing errors

  1. Unknown properties
  2. Illegal values
  3. Malformed declarations
  4. Invalid at-keywords
  5. Unexpected end of style sheet
  6. Unexpected end of string

a. Unknown properties

This paragraph should be only red.

p#red2 {color: red; lightness: 10%;}

Comments on test # 3

Only IE6 (Win) doesn't apply the 'color' declaration.

b. Illegal values

This paragraph should have no border.

p#border {border-width: 3}

Comments on test # 4

All browsers ignore the above declaration.

c. Malformed declarations

This paragraph should be green.

 p#green {color: green; color}

Comments on test # 5

Only IE6 (Win) doesn't apply the 'color' declaration.

d. Invalid at-keywords

This paragraph should not be green.

@media paper {
 p#green2 {color: green}
}

Comments on test # 6

All browsers ignore the above declaration.

e. Unexpected end of style sheet

This paragraph should be blue.

p#blue {color: blue

Comments on test # 7

Only Opera 9 and IE5 (Win) close the open parentheses and apply the declaration.

f. Unexpected end of string

This paragraph should be only green.

p {
color: green; 
font-family: 'Courier New Times
color: red; 
color: green;
}

Comments on test # 8

All browsers apply only the 'color: green' and 'color: green' declarations.