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