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