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