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