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