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