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