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