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