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