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