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