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