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