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