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