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