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