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