Housebaked!

What's New :

The Quickest Introduction to CSS!

May 9, 2008

If you're new to CSS this is the place to start! Real life examples with complete descriptions and step-by-step instructions. read more

Pre-Planning a Website

Apr 21, 2008

Every person new to Web Development should have a peek at this article. In depth advice on the pre-planning of your website in six simple steps. read more

The Linux Guide - Update!

Apr 10, 2008

TLG has been updated after we've received contribution to the project. Thanks Hazel! read more

Win Friends and Make Them Think Like You

Apr 06, 2008

How can we change the way the people around us think? I explain just how human nature works and how we can all be happier. read more

My Weblog

Mar 29, 2008

Here's my Weblog for the little things which don’t fit here and is a place where I’ll enjoy myself rather than being too serious. Visit my Blog

HTML Tutorial Part 2: Basic Styling and Formatting

Mar 26, 2008

Part 2 PreviewThere are numerous ways to style attributes of your page such as your font colours and so forth. I am not going to go over changing the colour of fonts in this part of the tutorials because I believe that changing font colours is a matter better resolved with CSS - which I will cover in another tutorial.

In the previous lesson you've already learnt about the <hr> tag which creates a horizontal rule over the screen. For now let's look at a few other ways to spice up your website. I suggest that you just modify the original code from the first part of this tutorial-set.

Adding a Title

We need to add a big title that will shout our page's name. We can do this with the <h1> to <h6> tags. 1 being the largest and 6 the smallest heading tag. Just above your navigation, add this.

<h1>My Cool Site!</h1>
<hr />

Text Formatting

In our layout we have "<p><a href="index.html">Home Page</a> - <a href="aboutme.html">About me</a></p>" that make up our links. To make the links look a bit bigger and attract some more attention we're going to use the <strong> tag to make the links a bit bolder.

So "<p><a href="index.html">Home Page</a> - <a href="aboutme.html">About me</a></p>" now becomes "<p><a href="index.html"><strong>Home Page</strong></a> - <a href="aboutme.html"><strong>About me</strong></a></p>". Here's a clearer view.

<p><a href="index.html"><strong>Home Page</strong></a> - <a href="aboutme.html"><strong>About me</strong></a></p>

Adding Images to Our Page

Adding images to your page can make a difference in usability and in some cases even bring over a message much clearer. Add the following line of code just below your paragraph in a new paragraph.

<p><img src="images/springbokemblem.jpg" width="150" height="150" title="Springbok Rugby Emblem" alt="Springbok Rugby Emblem" /><p/>

Will show...

Springbok Rugby Emblem

Here are a couple of things to notice.

  1. The image's location (directory).
  2. The width and height attributes.
  3. The title attribute.
  4. The alt attribute.

The width and the height should be change according to the size you want the image to display. Usually it's better to stick to the original size or rather crop the image with an image editing program instead of scaling it with the attributes which can lead to pixelation. We added the title attribute so that we can see the title (a short description) of the image when we hover our mouse over the image in our browser. Last but not least is the alt tag. This tag is very important and is required by W3C standards. The function of the alt tag is to show a description of the image in case it cannot load or in cases where people us text-based browsers so they can see a description of the image.

Google and other search engines might use the title attribute to assign certain keywords to your images when caching them so remember to label them well. The title attribute is not mandatory however and you can include or exclude them to images as you wish.

Final Product

Our final product should now look like this.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>My Home Page!</title>
</head>
<body>
<h1>My Cool Site!</h1>
<hr /> <p><a href="index.html"><strong>Home Page</strong></a> - <a href="aboutme.html"><strong>About me</strong></a></p>
<hr />
<p>Hallo, this is my first web page. I hope it will turn out OK!</p>
<p><img src="images/springbokemblem.jpg" width="150" height="150" title="Springbok Rugby Emblem" alt="Springbok Rugby Emblem" /></p>
</body>
</html>

Here's an example of what it will look like in your browser.

You can validate the page at http://validator.w3.org/.