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