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