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