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