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