CSS Worksheet: CSS Rules and Syntax
Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.
NameDateTime takenScore ___ / 40
- 1.✍️ Which sign ends each CSS declaration? (a) ; (b) , (c) : (d) .
-
2.✍️ How many declarations (property: value pairs) are in this rule?
li {
font-size: 20px;
background-color: yellow;
width: 300px;
} -
3.✍️ What value is given to width in this rule?
li {
width: 300px;
font-weight: bold;
background-color: yellow;
} (a) italic (b) 300px (c) width (d) red -
4.✍️ Which property is set to 2px solid in this rule?
p {
padding: 8px;
text-align: center;
font-size: 20px;
border: 2px solid;
} (a) border (b) font-style (c) width (d) 2px solid -
5.✍️ How many declarations (property: value pairs) are in this rule?
body {
margin: 10px;
} - 6.✍️ Which sign goes between a property and its value? (a) : (b) - (c) = (d) ;
-
7.✍️ Which property is set to 300px in this rule?
#top {
text-align: center;
width: 300px;
} (a) color (b) font-style (c) width (d) 300px -
8.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
background-color: yellow;
font-size: 20px;
} -
9.✍️ Which property is set to 8px in this rule?
p {
width: 300px;
padding: 8px;
} (a) border (b) 8px (c) font-weight (d) padding -
10.✍️ How many declarations (property: value pairs) are in this rule?
li {
margin: 10px;
padding: 8px;
color: red;
border: 2px solid;
} - 11.✍️ How does a CSS comment start? (a) # (b) <!-- (c) // (d) /*
-
12.✍️ What value is given to color in this rule?
li {
margin: 10px;
padding: 8px;
color: red;
text-align: center;
} (a) center (b) 20px (c) color (d) red -
13.✍️ Which property is set to 8px in this rule?
.box {
padding: 8px;
font-style: italic;
color: red;
} (a) font-weight (b) 8px (c) padding (d) border -
14.✍️ What is the selector in this CSS rule?
.note {
font-size: 20px;
border: 2px solid;
} (a) font-size (b) #top (c) 2px solid (d) .note -
15.✍️ What value is given to text-align in this rule?
body {
text-align: center;
font-style: italic;
font-weight: bold;
} (a) yellow (b) center (c) 10px (d) text-align - 16.✍️ In color: blue; which part is the value? (a) color (b) blue (c) : (d) ;
-
17.✍️ What value is given to text-align in this rule?
body {
text-align: center;
font-weight: bold;
background-color: yellow;
margin: 10px;
} (a) center (b) 10px (c) yellow (d) text-align -
18.✍️ What is the selector in this CSS rule?
.box {
color: red;
width: 300px;
margin: 10px;
font-size: 20px;
} (a) h2 (b) .box (c) 300px (d) color -
19.✍️ Which property is set to 300px in this rule?
.note {
width: 300px;
color: red;
} (a) 300px (b) font-style (c) color (d) width -
20.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-size: 20px;
margin: 10px;
} -
21.✍️ How many declarations (property: value pairs) are in this rule?
li {
color: red;
} -
22.✍️ How many declarations (property: value pairs) are in this rule?
p {
font-style: italic;
} - 23.✍️ In color: blue; which part is the property? (a) ; (b) blue (c) : (d) color
-
24.✍️ Which property is set to 300px in this rule?
body {
font-weight: bold;
width: 300px;
font-style: italic;
} (a) color (b) font-style (c) width (d) 300px - 25.✍️ CSS declarations go inside which brackets? (a) { } (b) < > (c) ( ) (d) [ ]
-
26.✍️ What value is given to font-style in this rule?
#top {
background-color: yellow;
border: 2px solid;
font-style: italic;
} (a) font-style (b) italic (c) 20px (d) red -
27.✍️ What is the selector in this CSS rule?
li {
margin: 10px;
padding: 8px;
text-align: center;
font-style: italic;
} (a) margin (b) body (c) li (d) 8px -
28.✍️ What is the selector in this CSS rule?
body {
font-style: italic;
width: 300px;
} (a) font-style (b) .box (c) 300px (d) body -
29.✍️ How many declarations (property: value pairs) are in this rule?
h1 {
border: 2px solid;
text-align: center;
font-weight: bold;
} -
30.✍️ How many declarations (property: value pairs) are in this rule?
.note {
padding: 8px;
border: 2px solid;
font-size: 20px;
background-color: yellow;
} -
31.✍️ Which property is set to red in this rule?
p {
color: red;
margin: 10px;
} (a) font-size (b) color (c) text-align (d) red -
32.✍️ Which property is set to center in this rule?
h1 {
text-align: center;
font-style: italic;
} (a) text-align (b) margin (c) background-color (d) center -
33.✍️ How many declarations (property: value pairs) are in this rule?
body {
width: 300px;
padding: 8px;
color: red;
border: 2px solid;
} -
34.✍️ What is the selector in this CSS rule?
.box {
font-weight: bold;
text-align: center;
width: 300px;
} (a) font-weight (b) .box (c) h2 (d) center -
35.✍️ What is the selector in this CSS rule?
h2 {
width: 300px;
text-align: center;
color: red;
font-size: 20px;
} (a) h2 (b) width (c) h1 (d) center -
36.✍️ What is the selector in this CSS rule?
h1 {
text-align: center;
font-weight: bold;
color: red;
width: 300px;
} (a) bold (b) text-align (c) h1 (d) p -
37.✍️ What value is given to font-size in this rule?
.note {
background-color: yellow;
font-weight: bold;
color: red;
font-size: 20px;
} (a) yellow (b) center (c) 20px (d) font-size -
38.✍️ How many declarations (property: value pairs) are in this rule?
#top {
text-align: center;
font-size: 20px;
font-weight: bold;
background-color: yellow;
} -
39.✍️ What is the selector in this CSS rule?
body {
font-size: 20px;
margin: 10px;
} (a) font-size (b) body (c) .box (d) 10px -
40.✍️ How many declarations (property: value pairs) are in this rule?
h2 {
color: red;
background-color: yellow;
}
Answer key
- ;
- 3
- 300px
- border
- 1
- :
- width
- 2
- padding
- 4
- /*
- red
- padding
- .note
- center
- blue
- center
- .box
- width
- 2
- 1
- 1
- color
- width
- { }
- italic
- li
- body
- 3
- 4
- color
- text-align
- 4
- .box
- h2
- h1
- 20px
- 4
- body
- 2
Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids