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