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