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