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