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