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