Example HTML

Presented by Netmouse

HTML is easy.
View: Page Source will get you the source code for any web page. Copy it. Modify it. Play around. This page was written in order to provide examples of HTML code. You have to look at the source to find out the code.
This isn't a comprehensive guide to HTML; the tags that have been left out are not here because I never use them. You don't need to know all of HTML in order to design a clean, informative web page. All you have to do is try it. It's easy.
Email me at netmouse@cyberspace.org if you have any questions.

All the things in the source code that are between angle brackets <like this> are HTML. An HTML file is just a text file with valid HTML code in it, named 'something.html'. Most HTML tags have an associated closing tag so make a note of when to use them. Good luck.

Text Modifiers - Fonts - Colors - Sizes and Headings - Spacing - Lists - Lines - Tables - Images - Forms - Style


Text Modifiers
This is bold
This is italic
Bold italic is more legible than italic in most fonts
This is underline
Newer browsers support strike

Fonts
Default | Arial | Verdana | Comic Sans MS | Courier | Garamond | Tahoma | Times | Symbol
That's an incomplete list: installed fonts will vary. Not everyone will have the font you want to use installed on their machine; you can set up options to handle that possibility.
(This is in Helvetica, but is Arial if the viewer's computer doesn't have Helvetica, Times if they don't have Helvetica or Arial.)

Colors
Colors are defined in hexadecimal RGB. Some browsers support the use of color names.
red | green | blue | light blue | neon green | yellow | orange | pink | dark green | dark red | dark blue | purple | violet | grey | white | black

Go ahead and play with the numbers, see what you get. RGB stands for red green blue; the first two digits of the hexadecimal number affect red light, the next two green light, and the last two blue light. Light doesn't mix like paint, so it's a little bit hard at first. Larger numbers generally mean a brighter appearance.
What's a two-digit hexadecimal number? It counts like this:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 ... E9 EA EB EC ED EE EF F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
The middle of the range is about 7F. Not everyone has this many colors on their computer. There are web sites and tools that will provide you with "safe" sets of colors that will display on most computers. Do note however that some people have machines or browsers that don't display color at all.

Text, link, viewed link, and active link colors can be set in the body tag. The defaults are To avoid confusing your viewer, I recommend leaving link colors alone. Do not use underlined text in a standard link color that is not, in fact a link. It's confusing.
Set the background color of your page with the bgcolor value in the body tag. If you use a very dark bgcolor, you need to reset all the text and link colors so people can still read your text and links.

Sizes and Headings
The base font size is size="3".
This is one size larger
You can also specify font in a relative manner, with size="+1" or size="-1", etc.
This is the largest font
This is the smallest font

Mixing font sizes can give you An Attractive Title Appearance

Headings have space above and below them, set sizes, and are bold. You can also set their alignment:

This is the largest header

This is the next largest header, centered

This is a smaller header, aligned right

The headers get smaller as the number of the header goes up

This is the smallest header
Even the smallest header has lots of space around it.

Speaking of Space...
To execute a single line break, do this.
To create a paragraph division, (a break plus one line of space) do this

The only reason to ever use the open and close brackets for paragraph is in order to do alignment,

Like this.

If you need lots of empty space, multiple paragraphs will do you no good with no text. Use multiple line breaks instead.




You can also specify    S  P   A    C   I   N  G and
   indent a specific number of spaces with the non-breaking space.

(spaces larger than one space and line breaks in your code are invisible to
the browser. If you want space in the display, you have to put it there.)

This is centered text.

Lists
Lists allow you to indent things by regular, set amounts of space. They also have space above and below them (like headers).
This is a data list
It allows you to indent things
without putting in a line marker
    This is an ordered list.
  1. The default type of line marker is numerical
    1. You specify the type by giving the first indicator of that type.
      1. standard types are available
    2. If you wonder if a variation is there, try it. Capital letters, roman numerals, etc.
  2. This is useful for not having to keep count as you modify a numbered list.
However,
  • If you want to put a bullet with no indent, you can do that too.

    And, with a DD you can
    indent without the space above
    and below.
    Blockquote spaces your text away from the edge of the page in the right margin as well as the left margin. Before blockquote, you had to use tables to do that.
    Horizontal Rule
    The horizontal rule is an attractive and versatile straight line.
    By default it is as wide as the page, centered, shaded, and of size 1.

    Usually I prefer to put space between my rules and my text.

    You can increase the size:


    You can make it solid instead of shaded:


    You can vary the width proportionally (varies with the width of the window; resize your browser window to see the effect) or to a set pixel count:



    And you can vary the alignment:


    Many people use a long thin image instead of a horizontal rule, like this:

    Rainbow line

    Tables
    Tables can vary in width like horizontal rules. If you want to do fancy formatting with them, always use closing tags. If you forget to close a table, the entire rest of the page will be broken, and nothing from the broken table on down will show up.

    By default, a table will turn out as wide as the browser thinks is necessary, and have no border.

    Also by default, items in a table row will be vertically aligned center.

    your browser will try to make things evenly spaced. The border has been turned on in this table so you can see the spacing.
     

    In order to make an empty table cell show up, you have to use a non-breaking space and a break or paragraph {or a clear image; see below}, because some browers will ignore an empty TD completely


    I recommend vertically aligning your rows to the top.


    You can override that for a particular cell.
    You can also center text. Or align it to the right.

    Tables themselves can be aligned left
    Or right
    Or center

    An aligned table is good
    for special
    announcements
     

    Aligning tables to one side or the other allows you to mix tables with text in the same line.
    Note that in the source code the table comes before the text, though on the page it looks like the table follows the text.

    If you want to force a table cell to include your lines without wrapping except where specified by line breaks, you can do that.
    It doesn't always hold, but it works most of the time.
    But that might force another cell off the page, and/or make it really thin.

    A table border can be used to give the impression of depth

    Cellspacing increases the space between cells

    Cellpadding increases the padding between text and border

    Some possible table formats/tricks:

     

    (HEADER)
    (Text)

    If you want to set table and inner cell widths, either set them proportionally {50%} or specifically {250}; if you mix the two types of setting it won't work.


    Remember:
    You can use rules in tables, but you have to set their size so they don't dominate the table spacing.

     

    Note
    The color of the table beneath (or the bgcolor or background image of the page) shows through in the spaces around and between the cells of your inner table.

    To avoid that (as on the left), set cellspacing to zero in your inner table and set the cellpadding of the outside [or bottom] table to zero also.
    However, this effect can be used purposefully to achieve a colored frame.

    Index

    Header

    Main Content

    This is the Header
    Index

    BLAH
    BLAH
    blah
    ... etc.

    (clear dot) .
    Main Content

    The line to the left is done with a td one pixel wide. A space is wider than 1 pixel, so to get a line that thin you have to use a transparent gif (cleardot.gif).

    The line in question is spanning two rows, using the rowspan variable.

    Notice how the header spans columns with colspan="#of columns" in the TD.

    Fancy formatting like those lines to the left generally takes some fooling around before it turns out right.

    .

    People often put their address on the left here

    Forms
    Images
    Images can be aligned left, center, or right, can have their heights and widths altered, and can have space put around them. They can be made into buttons by putting them in a link.You can make more complicated images by arranging them in tables, animating them, or using an imagemapto give different parts of an image different link destinations.

    Images are one of the most overused elements on the web. They take a horrendous amount of time to downloadand are often annoying or distracting. Use few images, and repeat them so the user doesn't have to reload them.Not all users will be able to see your images, so always use the alt tag to describe the image to the user.
    If you are going to put a link around an image, consider whether you want the border
    .
    ON
    OR .
    OFF

    Miscellaneous Style Points

    Text Modifiers - Fonts - Colors - Sizes and Headings - Spacing - Lists - Lines - Tables - Images - Forms - Style

    [Top of the Page]