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