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