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