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