Test your skills: Values and units
The aim of this skill test is to help you assess whether you understand different types of values and units used in CSS properties.
Note: To get help, read our Test your skills usage guide. You can also reach out to us using one of our communication channels.
Task 1
In this task, the first list item has been given a background color using a hex color code. Complete the CSS using the same color in different formats, plus a final list item where you should make the background semi-opaque.
- The second list item should use RGB color.
- The third should use HSL color.
- The fourth should use RGB color but with the alpha channel set to
0.6.
You can convert the hex color at convertingcolors.com. You need to figure out how to use the values in CSS. Your final result should look like the image below:

<ul>
<li class="hex">hex color</li>
<li class="rgb">RGB color</li>
<li class="hsl">HSL color</li>
<li class="transparency">Alpha value 0.6</li>
</ul>
body {
font: 1.2em / 1.5 sans-serif;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 1em;
padding: 0.5em;
}
.hex {
background-color: #86defa;
}
/* Add styles here */
Click here to show the solution
By using a color conversion tool, you should be equipped to use different color functions to define the same color in different ways:
.hex {
background-color: #86defa;
}
.rgb {
background-color: rgb(134 222 250);
}
.hsl {
background-color: hsl(194 92% 75%);
}
.transparency {
background-color: rgb(134 222 250 / 60%);
}
Task 2
In this task, we want you to set the font size of various items of text:
- The
<h1>element should be50px. - The
<h2>element should be2em. - All
<p>elements should be16px. - A
<p>element that is directly after an<h1>should be120%.
Your final result should look like the image below:

<h1>Level 1 heading</h1>
<p>
Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion
daikon amaranth tatsoi tomatillo melon azuki bean garlic.
</p>
<h2>Level 2 heading</h2>
<p>
Gumbo beet greens corn soko endive gumbo gourd. Parsley shallot courgette
tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato.
Dandelion cucumber earthnut pea peanut soko zucchini.
</p>
body {
font: 1.2em / 1.5 sans-serif;
}
h1 {
/* Add styles here */
}
h2 {
/* Add styles here */
}
p {
/* Add styles here */
}
h1 + p {
/* Add styles here */
}
Click here to show the solution
You can use the following length values:
h1 {
font-size: 50px;
}
h2 {
font-size: 2em;
}
p {
font-size: 16px;
}
h1 + p {
font-size: 120%;
}
Task 3
To complete the task, update the CSS to move the background image so that it is centered horizontally and is 20% from the top of the box.
Your final result should look like the image below:

<div class="box"></div>
.box {
border: 5px solid black;
height: 350px;
}
.box {
background-image: url("https://mdn.github.io/shared-assets/images/examples/purple-star.png");
background-repeat: no-repeat;
}
Click here to show the solution
Use background-position with the center keyword and a percentage:
.box {
background-image: url("https://mdn.github.io/shared-assets/images/examples/purple-star.png");
background-repeat: no-repeat;
background-position: center 20%;
}