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