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