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