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