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