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