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