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