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