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