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