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