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