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