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