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