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