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