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