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