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