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