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