Challenge: Styling a biography page
Learnwebdevelopment/Core/Stylingbasics/Basicselectors
Learn_web_development/Core/Styling_basics/Basic_selectors
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.
```html live-sample___style-bio-start live-sample___style-bio-finish
Jane Doe
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.
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.
Contact information
- Email: jane@example.com
- Web: http://example.com
- Tel: 123 45678
```css live-sample___style-bio-start
html {
background-color: white;
}
body {
font: 1.2em / 1.5 system-ui;
}
100%
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 of20pxon 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 of30pxon 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 a10pxdotted bottom border, which uses the CSS color keywordpurple. - Make the level two heading italic.
- Give the level one heading a font size of
2remand the level two heading a font size of1.5rem. - Select the
<div>using a class selector, and give it a color ofdarkslategrayand a bold font weight. - Make the links
green. - Make the links
darkgreenwhile hovered over with the mouse pointer or focused via the keyboard (you'll need to use a couple of pseudo-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:
100%
Click here to show the solution
The CSS applied to the finished live sample looks like this: ```css live-sample___style-bio-finish 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 - widthLearn_web_development/Core/Styling_basics/Basic_selectors