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