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