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