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