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