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