Wednesday, August 6, 2008

Markup Tags



HTML

This element tells your browser that the file contains HTML-coded information. The file extension .html also indicates this an HTML document and must be used. (If you are restricted to 8.3 filenames (e.g., LeeHome.htm, use only .htm for your extension.)

HEAD

The head element identifies the first part of your HTML-coded document that contains the title. The title is shown as part of your browser's window (see below).

TITLE

The title element contains your document title and identifies its content in a global context. The title is typically displayed in the title bar at the top of the browser window, but not inside the window itself. The title is also what is displayed on someone's hotlist or bookmark list, so choose something descriptive, unique, and relatively short. A title is also used to identify your page for search engines (such as HotBot or Infoseek).

For example, you might include a shortened title of a book along with the chapter contents: NCSA Mosaic Guide (Windows): Installation. This tells the software name, the platform, and the chapter contents, which is more useful than simply calling the document Installation. Generally you should keep your titles to 64 characters or fewer.

BODY

The second--and largest--part of your HTML document is the body, which contains the content of your document (displayed within the text area of your browser window). The tags explained below are used within the body of your HTML document.

Headings

HTML has six levels of headings, numbered 1 through 6, with 1 being the largest. Headings are typically displayed in larger and/or bolder fonts than normal body text. The first heading in each document should be tagged

.

The syntax of the heading element is:
Text of heading
where y is a number between 1 and 6 specifying the level of the heading.

Do not skip levels of headings in your document. For example, don't start with a level-one heading (

) and then next use a level-three (

) heading.

Paragraphs

Unlike documents in most word processors, carriage returns in HTML files aren't significant. In fact, any amount of whitespace -- including spaces, linefeeds, and carriage returns -- are automatically compressed into a single space when your HTML document is displayed in a browser. So you don't have to worry about how long your lines of text are. Word wrapping can occur at any point in your source file without affecting how the page will be displayed.

In the bare-bones example shown in the Minimal HTML Document section, the first paragraph is coded as

Welcome to the world of HTML.
This is the first paragraph.
While short it is
still a paragraph!




In the source file there is a line break between the sentences. A Web browser ignores this line break and starts a new paragraph only when it encounters another

tag.

Important: You must indicate paragraphs with

elements. A browser ignores any indentations or blank lines in the source text. Without

elements, the document becomes one large paragraph. (One exception is text tagged as "preformatted," which is explained below.) For example, the following would produce identical output as the first bare-bones HTML example:

Level-one heading


Welcome to the world of HTML. This is the
first paragraph. While short it is still a
paragraph!

And this is the second paragraph.



To preserve readability in HTML files, put headings on separate lines, use a blank line or two where it helps identify the start of a new section, and separate paragraphs with blank lines (in addition to the

tags). These extra spaces will help you when you edit your files (but your browser will ignore the extra spaces because it has its own set of rules on spacing that do not depend on the spaces you put in your source file).

NOTE: The

closing tag may be omitted. This is because browsers understand that when they encounter a

tag, it means that the previous paragraph has ended. However, since HTML now allows certain attributes to be assigned to the

tag, it's generally a good idea to include it.

Using the

and

as a paragraph container means that you can center a paragraph by including the ALIGN=alignment attribute in your source file.


This is a centered paragraph.
[See the formatted version below.]





This is a centered paragraph.


It is also possible to align a paragraph to the right instead, by including the ALIGN=RIGHT attribute. ALIGN=LEFT is the default alignment; if no ALIGN attribute is included, the paragraph will be left-aligned.

Lists

HTML supports unnumbered, numbered, and definition lists. You can nest lists too, but use this feature sparingly because too many nested items can get difficult to follow.

Unnumbered Lists

To make an unnumbered, bulleted list,

start with an opening list
    (for unnumbered list) tag
    enter the
  • (list item) tag followed by the individual item; no closing
  • tag is needed
    end the entire list with a closing list
tag

Below is a sample three-item list:


  • apples
  • bananas
  • grapefruit



The output is:

apples
bananas
grapefruit

The
  • items can contain multiple paragraphs. Indicate the paragraphs with the

    paragraph tags.

    Numbered Lists

    A numbered list (also called an ordered list, from which the tag name derives) is identical to an unnumbered list, except it uses

      instead of
        . The items are tagged using the same
      • tag. The following HTML code:


        1. oranges
        2. peaches
        3. grapes



        produces this formatted output:

        oranges
        peaches
        grapes

        Definition Lists

        A definition list (coded as
        ) usually consists of alternating a definition term (coded as
        ) and a definition definition (coded as
        ). Web browsers generally format the definition on a new line and indent it.

        The following is an example of a definition list:


        NCSA
        NCSA, the National Center for Supercomputing
        Applications, is located on the campus of the
        University of Illinois at Urbana-Champaign.
        Cornell Theory Center
        CTC is located on the campus of Cornell
        University in Ithaca, New York.



        The output looks like:

        NCSA
        NCSA, the National Center for Supercomputing Applications, is located on the campus of the University of Illinois at Urbana-Champaign.
        Cornell Theory Center
        CTC is located on the campus of Cornell University in Ithaca, New York.

        The
        and
        entries can contain multiple paragraphs (indicated by

        paragraph tags), lists, or other definition information.

        The COMPACT attribute can be used routinely in case your definition terms are very short. If, for example, you are showing some computer options, the options may fit on the same line as the start of the definition.


        -i
        invokes NCSA Mosaic for Microsoft Windows
        using the initialization file defined in the path
        -k
        invokes NCSA Mosaic for Microsoft Windows in
        kiosk mode


        The output looks like:
        -i
        invokes NCSA Mosaic for Microsoft Windows using the initialization file defined in the path.
        -k
        invokes NCSA Mosaic for Microsoft Windows in kiosk mode.

        Nested Lists

        Lists can be nested. You can also have a number of paragraphs, each containing a nested list, in a single list item.

        Here is a sample nested list:


        • A few New England states:

          • Vermont
          • New Hampshire
          • Maine

        • Two Midwestern states:

          • Michigan
          • Indiana




        The nested list is displayed as

        A few New England states:
        Vermont
        New Hampshire
        Maine
        Two Midwestern states:
        Michigan
        Indiana
        Preformatted Text

        Use the
         tag (which stands for "preformatted") to generate text in a fixed-width font. This tag also makes spaces, new lines, and tabs significant -- multiple spaces are displayed as multiple spaces, and lines break in the same locations as in the source HTML file. This is useful for program listings, among other things. For example, the following lines: 
        


        #!/bin/csh
        cd $SCR
        cfs get mysrc.f:mycfsdir/mysrc.f
        cfs get myinfile:mycfsdir/myinfile
        fc -02 -o mya.out mysrc.f
        mya.out
        cfs save myoutfile:mycfsdir/myoutfile
        rm *



        display as:

        #!/bin/csh
        cd $SCR
        cfs get mysrc.f:mycfsdir/mysrc.f
        cfs get myinfile:mycfsdir/myinfile
        fc -02 -o mya.out mysrc.f
        mya.out
        cfs save myoutfile:mycfsdir/myoutfile
        rm *


        The
         tag can be used with an optional WIDTH attribute that specifies the maximum number of characters for a line. WIDTH also signals your browser to choose an appropriate font and indentation for the text. 
        

        Hyperlinks can be used within
         sections. You should avoid using other HTML tags within 
         sections, however. 
        

        Note that because <, >, and & have special meanings in HTML, you must use their escape sequences (<, >, and &, respectively) to enter these characters. See the section Escape Sequences for more information.

        Extended Quotations

        Use the
        tag to include lengthy quotations in a separate block on the screen. Most browsers generally change the margins for the quotation to separate it from surrounding text.

        In the example:

        Omit needless words.



        Vigorous writing is concise. A sentence should
        contain no unnecessary words, a paragraph no unnecessary
        sentences, for the same reason that a drawing should have
        no unnecessary lines and a machine no unnecessary parts.


        --William Strunk, Jr., 1918





        the result is:

        Omit needless words.


        Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.


        --William Strunk, Jr., 1918

        Forced Line Breaks/Postal Addresses


        The
        tag forces a line break with no extra (white) space between lines. Using

        elements for short lines of text such as postal addresses results in unwanted additional white space. For example, with
        :

        National Center for Supercomputing Applications

        605 East Springfield Avenue

        Champaign, Illinois 61820-5518


        The output is:

        National Center for Supercomputing Applications
        605 East Springfield Avenue
        Champaign, Illinois 61820-5518



        Horizontal Rules

        The


        tag produces a horizontal line the width of the browser window. A horizontal rule is useful to separate major sections of your document.

        You can vary a rule's size (thickness) and width (the percentage of the window covered by the rule). Experiment with the settings until you are satisfied with the presentation. For example:




        displays as:
  • No comments:

    Search

    My Blog List