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