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