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