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