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