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