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