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