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