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