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