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