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