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