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