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