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