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