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