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