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