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