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