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