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