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