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