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