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