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