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