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