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