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