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