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