In this lesson we're going to look at the Anatomy of a Web Page, a basic look at some of the more common structures that make up a web page. Even if you're not writing your HTML by hand, it's important to be able to recognize some of these things, particularly when you come to do your search engine optimization.
Let's start right at the top!
The doctype declaration at the start of a web page is actually an instruction to tell a web browser what version of HTML it's written in. It used to be that you would read something like
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Fortunately these days, HTML has been simplified a little, and all you have to write in that doctype declaration is:
When you make a webpage, it will always include these two tags. They wrap around pretty much everything else on your page, to say "this is HTML".
This part of the page is invisible when you look at the page in a browser, but provides the browser and the search engines with information about your page. Most importantly it houses your title and your meta tags.
It might also tell the browser where to find any stylesheet files that you're using to set the colors, fonts and other styles for your site, or any scripts that you might be running on that page.
What you put in between your title tags is the text that you want to appear at the top of your window when you look at your webpage; a lot of people neglect this when they build their pages! This is frequently the clickable text that ends up appearing in your search listing in the search engines as well, so it's good to put a couple of your keywords into your title tags. For instance:
<title> Pie Recipes | Key Lime Pie Recipe </title>
These also go inside your <head> section.They're meant to supply information to the search engines about how you want your page to be indexed: for instance, what the keywords are for your page, what description you want used in the search engine search listing, whether you want your page to be cached, etc.
This is the main part of your webpage: the part that houses the stuff that people actually see.
<h> tags denote headers throughout your text; <h1> is your "main header", <h2> is a sub-header, <h3> is a sub-sub-header, and so on, all the way to <h6>. For instance:
<h1> Key Lime Pie Recipe </h1>
<h2> Ingredients </h2>
<h3> Ingredients for the base:</h3>
(Base ingredients go here)
<h3> Ingredients for the filling:</h3>
(Filling ingredients go here)
<h2> Method </h2>
(How to make the pie goes here!)
Your <h1> headers are particularly important for search engine optimization - you should try to put your keywords into your <h1> headers (while obviously keeping it looking natural). <h2> headers can also have a little bit of an impact, so don't neglect those.
Links are the text you click to jump from one page to another. A basic link looks like this:
<a href="http://www.example.com/page2.html"> Click here to go to page 2! </a>
The first part of the link starts with a href= (the 'a' part specifies that the tag is an anchor, while the href specifies that it the anchor contains a hypertext reference)
The address of the page or site you want to link to goes in between the "" marks after that (ie, in place of the http://www.example.com/page2.html above)
The second part of the link is the text or image that you want your visitors to see. It can be plain text (like we have above) or it could be an image.
The third part of the link is what "closes" the link, and always looks like: </a>. If you don't close the link, you may find your entire page turns into one giant link!
The HTML for inserting an image into your page looks like this:
There is some extra information that you can insert into your image tag:
height and width: these are fairly self explanatory: you can specify the height and the width of the image in pixels.
<img src="/img/someimage.jpg" height="240" width="360">
This is useful because it tells the browser how much space to leave for images when it is rendering the page. This is good if you have lots of images, or really big images that take a while to load - otherwise your readers may find the text they're reading on a page is leaping around all over the place while the images on the page load.
You can also resize images using the height and width values, but this isn't recommended - not only will your images end up distorted, but your viewers still have to download the whole image in its full-sized glory, and it will still take just as long to load. It's just made to appear smaller.
alt: short for alternative text, this is the text that is displayed if, for some reason, the image doesn't load. The alt text is important for:
<img src="/img/someimage.jpg" height="240" width="360" alt="Here be my descriptive text">
Lists are extremely useful and deceptively powerful little things;
There are two main types of lists: the ordered list, and the unordered list.
The unordered list basically has no order. Each item has the same type of bullet. You can also have indented lists, like so:
<li>Cut a slice of bread using a big sharp knife</li>
<li>Put the bread in the toaster</li>
<li>Push down the "toast" lever of the toaster</li>
<li>Wait a few minutes until toast pops</li>
<li>Spread toast with topping of your choice</li>
An ordered list will use numbers, letters or roman numerals as the bullet; you can specify the type of ordering in your CSS. Also, as with unordered lists, you can have multiple levels of indentation.
If you've ever clicked a "submit" button, or sent a support request to a business through their website, you've used a form. Forms are parts of a page where your user can enter information through textboxes, drop-down lists, checkboxes and buttons.
<form name="input" action="html_form_action.asp" method="get">
First name: <input type="text" name="firstname"> <br />
Last name: <input type="text" name="lastname"> <br />
<input type="radio" name="sex" value="male"> Male <br />
<input type="radio" name="sex" value="female"> Female <br />
<input type="checkbox" name="vehicle" value="Bike"> I have a bike <br />
<input type="checkbox" name="vehicle" value="Car"> I have a car <br />
<input type="checkbox" name="vehicle" value="Airplane">I have an airplane <br />
<input type="submit" value="Submit">
These are some other tags you will encounter inside your HTML
<p>...</p> You might have already encountered these tags in previous lessons. They're "paragraph" tags that wrap, unsurprisingly, around paragraphs.
<strong>...</strong> Represents text that you want to have strong emphasis, or importance. In most browsers it has the effect of making the text bold.
<em>...</em> Means "emphasis", and typically has the effect of making text italic.
<br /> Creates a line break, similar to hitting "return" once on your keyboard. It doesn't need a closing twin.
In this lesson we've taken a look at the basic anatomy of a web page and how each section makes up different parts of a web page. The areas we looked at include: