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