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