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