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