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