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