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