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