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