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