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