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