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