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