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