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