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