Cafe LaTe Home
Contents
Background
Getting Started
Images
Links
Tables
Lists
Resources
Tag Index
Page Layout Basics

Section One - Getting Started:
   Lesson 2-7: Page Layout Basics



   To wrap up this section, let's look at a few simple elements which will help you with page layout.

   Many people like to use horizontal lines to mark off sections in their pages. In HTML, a simple horizontal rule tag will draw a horizontal line on your page. Since a line doesn't contain anything, it is not a paired tag. The tag looks like this:

hr    HR stands for Horizontal Rule.

With some common attributes added, it looks like this:

hr align="center" size="3" width="350"

This rule displays like this on your screen:


   If you just use a simple hr tag, a line of standard thickness will be drawn all the way across the page from left to right. The ALIGN attribute lets you align the rule left, right, or center. The SIZE attribute lets you designate the thickness of the line in pixels. The WIDTH attribute let's you set the width of the line in pixels. The hr tag gives you a quick and easy way to divide your page into sections.

   Some elements like hr and p/p let you use the ALIGN attribute for positioning, but many other tags do not. However, there is a way to center just about anything on a web page. The tag looks like, you guessed it, this:

center/center

   Just about anything can be centered with center/center tags. center is a very simple and very convenient tag, but I am going to recommend that you avoid using this tag. Why? First, because there is a better tag. With the center/center tags you can align things to the center of the page, but not to the left or the right. There is another element that let's you align things left, right, or center - the div/div tag.

   With the div/div tags, you can align text, images, and other things to the left, the right, or the center. DIV is short for Division, because it divides your page into sections - or divisions. The tag (with an ALIGN attribute) looks like this:

        div align="center"/div

But, you ask, why use the div tag when the center tag is does the same thing and is a lot simpler? Well, center is simpler, but that is part of the problem. div allows you all alignment choices, and much more as well. But there is another more important reason not to use center. center will not be included in future versions of HTML. It is scheduled to be replaced by div, so it is better to avoid it if at all possible. To see how div works, take a look at the following examples:

Source HTML Result:
div align="LEFT"
HEADLINE NEWS
/div
displays as . . .
HEADLINE NEWS

div align="center"
HEADLINE NEWS
/div
displays as . . .
HEADLINE NEWS

div align="right"
HEADLINE NEWS
/div
displays as . . .
HEADLINE NEWS




Practice:

   Let's try out the HTML tags you just learned. Open your practice file again with Notepad or another text editor. Next, add a horizontal rule hr> just before the sentence:

This text is large, larger, and even larger still.


Add another hr> tag just after the sentence:

This text is red, green, blue, and pink.


Then, using the div> tag, center the two sentences. Everything between the two hr> tags should be centered, but not the horizontal rules themselves. Finally, add line breaks with the br> tag to add space where suitable to make it look good.

When finished, save your file, and look at it with your browser.
To see what the finished result should look like, click here!
Also, try resizing the popup window to see how window size affects the way the page is displayed.




Review:
  • The hr> tag is used to draw horizontal dividing lines on a page.
  • The hr> tag can take the align, size, and width attributes.
  • Almost anything can be centered with the center> element, but its use is not recommended.
  • The div> element can align divisions of your page left, right, or center. Always use div for alignment.



Congratulations, you have now completed all of the lessons in the Getting Started section. It's now time to check your understanding. Go on to the next page for a self-scoring quiz. Don't worry, your score is not recorded. You can take the quiz as many times as you like. Also, remember that when your answer is not correct you should look at the top of the page for feedback and helpful explanations.


 
Previous Lesson Next Lesson
 

[Cafe LaTe Home] [Chat Lounge] [Community Center] [Newspaper] [HTML Tutor]



Last revision: 2002/03/04, Copyright © The Three Cities Workshop