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