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