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