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