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