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