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