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