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