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