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