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