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