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