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