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