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