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