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