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