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