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