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