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