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