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