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