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