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