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