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