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