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