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