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