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