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