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