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