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