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