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