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