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