Challenge: Styling a biography page
In this challenge you will style a simple biography page, testing you on some of the skills you learned in the last couple of lessons including writing selectors, coloring backgrounds, and text styling. We will also invite you to look up some basic CSS features that we haven't covered, to test your research skills.
Starting point
To begin, click the Play button in one of the code panels below to open the provided example in the MDN Playground. You'll then follow the instructions in subsequent sections to style the page appropriately.
<h1>Jane Doe</h1>
<div class="job-title">Web Developer</div>
<p>
Far far away, behind the word mountains, far from the countries Vokalia and
Consonantia, there live the blind texts. Separated they live in Bookmarksgrove
right at the coast of the Semantics, a large language ocean.
</p>
<p>
A small river named Duden flows by their place and supplies it with the
necessary regelialia. It is a paradisematic country, in which roasted parts of
sentences fly into your mouth.
</p>
<h2>Contact information</h2>
<ul>
<li>Email: <a href="mailto:jane@example.com">jane@example.com</a></li>
<li>Web: <a href="http://example.com">http://example.com</a></li>
<li>Tel: <a href="tel:12345678">123 45678</a></li>
</ul>
html {
background-color: white;
}
body {
font: 1.2em / 1.5 system-ui;
}
Project brief
Follow the instructions below to style the bio. Try looking up the CSS features you'll need in the MDN CSS reference.
Box styles
- Give the
<body>
element a padding of20px
on all sides and a width of500px
. - Give the
<body>
element a background color of#efefef
(a light-gray<hex-color>
value). - Center the
<body>
element inside the viewport by setting top- and bottom-margins of0
, and left- and right-margins ofauto
. - Give the
<ul>
used for the contact details a background color ofwhite
, and a 5px solid purple border on all sides. Give the<ul>
padding of30px
on all sides to push the content away from the border. - Give the
<ul>
a border radius of20px
.
Text styles
- Make the level one heading dark gray, using the CSS color keyword
darkslategray
, and give the heading a10px
dotted bottom border, which uses the CSS color keywordpurple
. - Make the level two heading italic.
- Give the level one heading a font size of
2rem
and the level two heading a font size of1.5rem
. - Select the
<div>
using a class selector, and give it a color ofdarkslategray
and a bold font weight. - Make the links
green
. - Make the links
darkgreen
while hovered over with the mouse pointer or focused via the keyboard (you'll need to use a couple ofpseudo-classes
for this). - Make the links lose their underline while hovered or focused.
Hints and tips
- Use the W3C CSS Validator to catch unintended mistakes in your CSS — mistakes you might have otherwise missed — so that you can fix them.
- Try looking up some more advanced CSS features (again, the MDN CSS reference will be useful here) and add some more styles to your solution. Get adventurous!
- Remember that there is no wrong answer here — at this stage in your learning you can afford to have a bit of fun.
Example
Your finished example should end up looking something like this:
Click here to show the solution
The CSS applied to the finished live sample looks like this:
html {
background-color: white;
}
body {
font: 1.2em / 1.5 system-ui;
padding: 20px;
width: 500px;
background-color: #efefef;
margin: 0 auto;
}
h1 {
color: darkslategray;
border-bottom: 10px dotted purple;
font-size: 2rem;
}
h2 {
font-style: italic;
font-size: 1.5rem;
}
.job-title {
color: darkslategray;
font-weight: bold;
}
ul {
background-color: white;
border: 5px solid purple;
padding: 30px;
border-radius: 20px;
}
a {
color: green;
}
a:hover,
a:focus {
color: darkgreen;
text-decoration: none;
}
The CSS properties we used to solve the challenge are as follows — each one links to its property page on MDN, which will give you more examples of its use.
background-color
border
or related longhand properties.color
font-size
font-style
font-weight
margin
or related longhand properties.padding
or related longhand properties.text-decoration
width