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