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