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