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