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