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