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