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