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