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