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