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