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