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