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