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