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