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