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