Basic HTML Rules
There are five important rules
for coding with HTML tags.
1.Tags are always surrounded by angle brackets (less-than/greater-than characters), as in <head>.
2.Most tags come in pairs and surround the material they affect. They work like a light switch: the
first tag turns the action on, and the second turns it off. (There are some exceptions. For instance,
the <br> tag creates a blank line. To close it add a \ <br \>)
3.The second tag--the "off switch"--always starts with a forward slash. For example, you turn on bold
with <b>, shout your piece, and then go back to regular text with </b>.
4.First tag on, last tag off. Tags are embedded, so when you start a tag within another tag, you have
to close that inner tag before closing the outer tag. For instance, the page will not display properly
with the tags in this order:
<head><title>Your text</head></title>.
The correct order is:
<head><title>Your text</title></head>.
5.Many tags have optional attributes that use values to modify the tag's behavior. The <p>
(paragraph) tag's align attribute, for instance, lets you change the default (left) paragraph
alignment. For example, <p align="center"> centers the next paragraph on the page.
What Tags Do I Need?
There are certain tags you need to put in every HTML document to set it up as a Web page. Begin by
opening a new document in your text editor.
<html> is the first tag to appear on every Web page. Add the opening and closing tags to your page like
this:
<html>
</html>
All of the page's code will be placed between these two tags, which tell a Web browser it's reading an
HTML document.
<head>
Below the opening <html> tag, enter the <head> tag, which contains information about the document
but doesn't appear on the Web page. Your document should now look like this:
<html>
<head>
</head>
</html>
<title>
There are several tags that can go between <head> tags--for example, you'll regularly come across
<meta> tags that help search engines categorize pages--but the only tag that's required is the <title>
tag, which puts text in the browser's title bar. Your document should now resemble the example below
(remember: First on, last off):
<html>
<head>
<title>CAS 483
</title>
</head>
</html>
<body>
Now you're ready to add opening and closing <body> tags. Your document should now look like this:
<html>
<head>
<title>CAS 483
</title>
</head>
<body>This is the part on the page.
</body>
</html>
Everything that appears inside the Web page will go between the <BODY> tags.
The <BODY> tag uses several important attributes to control the look of your page. Use the BGCOLOR
attribute and value to change your page's background color. Version 3.x and later browsers can read
some colors from a list of standard English words, such as white, blue, black, and the like. But to take
advantage of all Web-safe colors, you'll need to use hexadecimal color codes. By selecting several colors at once, you can quickly create an entire color scheme for
your site. Keep in mind that most browsers can display colors from a palette of only 256 different hues and shades.
If you use a color that's not in the palette, the browser will try to choose a similar one. If you want to
guarantee that your colors will appear as close to your original choices as possible, select colors from
Netscape's 216 browser-safe colors. To keep things simple, use a plain white background. The hexadecimal code
for white is #FFFFFF, here is the code::
<body bgcolor="#FFFFFF">
Basic Formatting:
<br>
<br> forces a line break without adding any white space after the tag. This tag is a good choice for
creating line breaks inside paragraphs. Keep in mind, though, that manually broken lines often look
awkward when a viewer's browser window is sized narrower than usual: the text runs across the screen,
wraps to the next line, and then breaks again a few words later. For that reason, stick to using <br> only
when you need to force a line break for reasons of design or content.
<p>
The <p> tag breaks the text and inserts a blank line, which is useful for separating paragraphs from each
other. By default, both the <br> and the <p> tags start the text following the tag on the left side of the
page, but the <p> tag's ALIGN attribute can change that. Use <p align=right> to align the paragraph
with the right side of the page or <p align=center> to center the paragraph.