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