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