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