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