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