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