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