Practice: Develop a Webpage Using HTML and CSS
Site: | Saylor Academy |
Course: | PRDV401: Introduction to JavaScript I |
Book: | Practice: Develop a Webpage Using HTML and CSS |
Printed by: | Guest user |
Date: | Monday, October 7, 2024, 10:23 AM |
Description
Now it's time to practice developing a small webpage using HTML and CSS. In this example, you'll create a biography webpage using font, color, and text-decoration styles. Watch what happens to the biography text by changing the style.
You can also try this example using an editor and a web browser. The HTML file to start this exercise can be found at this link.
Introduction
With the things you have learned in the last few lessons you should find that you can format simple text documents using CSS to add your own style to them. This assessment gives you a chance to do that.
Prerequisites: | Before attempting this assessment you should have worked through the rest of the CSS basics module, and also have an understanding of HTML basics (study Introduction to HTML). |
---|---|
Objective: | To have a play with some CSS and test your new-found knowledge. |
Source: Mozilla, https://developer.mozilla.org/en-US/docs/Learn/CSS/First_steps/Using_your_new_knowledge
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Starting point
You can download the starting point file to work with in your own editor. This is a single page containing both the HTML and the starting point CSS (in the head of the document). If you prefer you could move this CSS to a separate file when you create the example on your local computer. Alternatively use an online tool such as CodePen, jsFiddle, or Glitch to work on the tasks.
Working with CSS
The following live example shows a biography, which has been styled using CSS. The CSS properties that I have used are as follows – each one links to its property page on MDN, which will give you more examples of its use.
In the box below, you will find some CSS already in place. This selects parts of the document using element selectors, classes, and pseudo-classes. Make the following changes to this CSS:
- Make the level one heading pink, using the CSS color keyword
hotpink
. - Give the heading a 10px dotted
border-bottom
which uses the CSS color keywordpurple
. - Make the level 2 heading italic.
- Give the
ul
used for the contact details abackground-color
of#eeeeee
, and a 5px solid purpleborder
. Use somepadding
to push the content away from the border. - Make the links
green
on hover.
You should end up with something like this image.
Afterwards try looking up some properties not mentioned on this page in the MDN CSS reference and 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.
Jane Doe |
Web DeveloperFar 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
|
CSS and HTML
body {
font-family: Arial, Helvetica, sans-serif;
}
h1 {
color: #375e97;
font-size: 2em;
font-family: Georgia, 'Times New Roman', Times, serif;
border-bottom: 1px solid #375e97;
}
h2 {
font-size: 1.5em;
}
.job-title {
color: #999999;
font-weight: bold;
}
a:link, a:visited {
color: #fb6542;
}
a:hover {
text-decoration: none;
}
<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: 123 45678</li>
</ul>