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