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