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