Scintography Home
Previous ChapterTable of ContentsNext Chapter
Title Page

Chapter 5: Formatting Pages with HTML


The Art of Scintography
Edition 3.0 © 2008 Aurora Isaac
www.scintography.com
    5.1   Arranging Your Page
      Once you have collected your site content, you need to arrange it on your page. This is done by specifying instructions with a markup language. A variety of markup protocols are available today, including HTML XHTML, XML, and others. If you are just starting, and plan to implement and maintain your own site, start with HTML. It is the most forgiving of all markup languages. How you arrange the elements of your page will be strongly influenced by the extent of your markup knowledge. Fortunately, it doesn't take much HTML to make a nice looking page.
    5.2   About HTML
      HTML, or Hyper Text Markup Language, was the first widely-used document formatting protocol on the Internet. Since then, a number of protocols have been built around this foundation. Many aspects of HTML have become nearly obsolete with the advent of protocols such as STYLE and XML, while others are so new they are as yet thinly supported within the HTML developers community. Understanding basic HTML is essential to understanding the expanded capability of the newer protocols built around it.
      HTML is a simple text markup language that can be edited into a text file with any editor or word processor that can output a text only format. HTML source documents should be saved into files with the suffix name .htm or .html. Such an HTML source document contains the text content you create for your viewers and HTML instructions for the browser program that displays your document. This instructional markup indicates to the browser how your document is to be displayed. For example, you may want your text to be white and your background to be black. You create a text file called "myfile.html" with your text editor. This file contains HTML instructions indicating white text and black background, as well as the text that will appear in this format. When a browser accesses your file, the instructions are interpreted and the text is displayed.
      HTML instructions, or tags, are contained in angle brackets: <TAGNAME>. Most tags are paired, and enclose the text that the formatting instructions apply to: <TAGNAME>Text to be formatted.</TAGNAME>. The closing tag includes a slash (/) preceding the tagname. These tag pairs are often referred to as containers. Many tags have attributes. These are defined within the opening tag:

<TAGNAME ATTRIBUTE="value">
Text to be formatted.
</TAGNAME>

The set of HTML tags and their attributes constitutes the HTML language. Browsers are generally very forgiving in their interpretation of HTML source. Your page may be formatted the way you want it, even if it has errors. Unfortunately, different browsers will probably handle the flaws in your code differently. As standards are incorporated into the process, interpretation will become more precise. It would be wise to keep your markup as accurate as possible, even where it may not seem neccessary.
<TAGNAME>

?

<tagname>
      HTML is a case-insensitive language. Tagnames and attributes may be in upper or lower case. Early developers used upper case so tags would stand out from the content. Although HTML is still case-insensitive, some of the newer markup languages require lower case tag and attribute names. If you are just starting, you might want to train yourself to use lower case, even for your HTML.
ATTRIBUTE="value"

?

ATTRIBUTE=value
      Attribute values are strings. They should be enclosed in 'single' or "double" quotes. However, browsers will recognize many values, especially sizes and colors, with no quotes. Values containing spaces, such as titles, should definitely be enclosed in quotes. Standards for some newer markup protocols require quotes for all attribute values. If you are just starting, use quotes until you are familiar with HTML standards.
<tagname>

?

</tagname>

?

<tagname/>
      Most HTML tags are paired. A </tag> beginning with a slash is a closing tag, and must always be preceeded by an opening <tag>. Some tags in HTML are unpaired. They are specified by a single opening <tag>. Newer, more strict protocols do not allow unpaired tags. Although you may continue to use the more lax protocols in HTML, you may see some tags in both paired and unpaired configurations. You may also see an unpaired <tag/> with a slash in front of the closing angle bracket. This is a shorthand way of indicating an empty container specified with only an opening tag.
      Colors and dimensions are often specified in attribute values. Colors in HTML are identified by their numerical code. Many colors also have names, which are aliases for their numerical codes. Use the Color Palette and Color Selector to find color names and numbers.
      Dimensions in HTML are specified in pixels or percentage. A dimension is specified without units to indicate pixels. A pixel is the smallest differentiable area on a screen. This is a relative unit, since different monitors use different numbers of pixels per inch. A dimension is specified with % to indicate percent of available space. Percentage dimensions resize with the window, but pixel dimensions do not.

    5.3   Using the Tutorials
      The easiest way to learn HTML is to see it in action. This text includes a series of "hands-on" interactive tutorials. Each lesson page has a menu button, a text area, and a "See This Page" button on the left. Each menu topic displays a portion of the tutorial. The text area contains the HTML source document code as it would appear in your editor. You can type into this text area. If you want to see the formatted document, click the "See This Page" button. The formatted document appears at the right. Each time you click the button, the document will be updated.
 
Menu


 
  See This Page  
The formatted document will appear in this space.

      These tutorials do not portray all possible tags, attributes, and values. Use them in conjunction with a good reference to explore the full possibility of hypertext markup.
     

! Browser Wars Alerts!

If you are just starting to make pages, you will be disappointed to hear that not all browsers interpret code in the same way. Although standards exist to provide consistency, variations still occur. Alerts will appear in the tutorials where significant differences may impact the appearance of your page.

I cannot guarantee that all variations will be noted. To insure the best (but not total) consistency, use a DOCTYPE statement to apply standards, then test your pages on as many platforms as possible.

    5.4   A Basic Page
 
   
HTML 1
      An HTML document is contained within the HTML tags. Within each document are two parts, the HEAD and the BODY:

<HTML>
  <HEAD>
The HEAD tag contents is loaded first. If your file contains special components such as scripts or style sheets, this content goes here.
  </HEAD>
  <BODY>
The BODY tag contents is loaded last. The content to be displayed on your page goes here.
  </BODY>
</HTML>

      Your browser may display text that is contained in any location, regardless of the tags included or not included. However, this is contrary to both the standards and conventions of the HTML markup language. For the most consistent formatting across platforms, keep your displayed content within the body of the document.
      Most HTML tags fall into one of two categories: inline tags and block tags. Inline tags format content within the line of text. These include font, bold, italic, etc. The contents of block tags are formatted in spaces that generally extend beyond a line of text, with formatted content starting on a new line. These include paragraph, blockquote, headings, etc.
      Since each tag was incorporated into HTML with a particular purpose, it is unlikely you will be combining tags in ways that will not produce the intended format. However, there are a couple of rules of thumb that will guide you in combining tags.
  1. Combined tags should be nested rather than staggered.
  2. Inline tags work and play well together, but block tags may not.
In general, combined tags should be nested. As development shifts toward the use of STYLE and other markup languages, nested containers will become the standard. Nesting, in contrast to staggering, creates a treelike structure within the document that can be formatted consistently and accessed and altered dynamically.
      HTML inline tags will generally work well either nested or staggered, and may be combined with block tags. This nested combination of inline tags:

<FONT COLOR="dodgerblue">
            dodgerblue font
      <B>
            combined with bold font
      </B>
            dodgerblue font
</FONT>

creates the expected output:
dodgerblue font combined with bold font dodgerblue font

This staggered combination of inline tags:

<FONT COLOR="dodgerblue">
            dodgerblue font
      <B>
            combination
</FONT>
            bold font
      </B>

though not recommended, also produces an expected output:
dodgerblue font combination bold font

Block tags do not always work well together, even nested. This nested combination of block tags:

<P ALIGN="right">
            paragraph aligned right
      <H3>
            combined with heading
      </H3>
            paragraph aligned right
</P>

causes the paragraph formatting to be unexpectedly altered by the insertion of the heading:

paragraph aligned right

combined with heading

paragraph aligned right


Since headings are intended to separate sections of text, paragraphs and headings should be sequential:

<P ALIGN="right">
            paragraph aligned right
</P>
<H3>
            heading
</H3>
<P ALIGN="right">
            paragraph aligned right
</P>

so the page will have the intended formatting:

paragraph aligned right

heading

paragraph aligned right


Of course, block tags do work well nested in many cases. Some block tags (especially table and div) are intended to be used to contain sections of a page that will include both block and inline tag formatting. In general, the more character a tag imparts, the less likely it will combine well with others. In other words, refrain from complex combinations with tags like marquees and lists.

HTML is evolving. Soon, STYLE will be an essential part of the language. Some of the tag attributes that are taught in these tutorials will be superceded by their STYLE counterparts. You may encounter reference to these features as deprecated attributes. They are taught here because they provide the foundation for the application of STYLE. Although HTML and STYLE have been relegated to separate chapters, you should consider them as two parts of a single markup language.
    5.5   Formatting Fonts
 
   
HTML 2
      Fonts are specified by enclosing the text to be formatted within a <FONT> container:

<FONT ATTRIBUTE="value">
Text to be formatted with font attribtue.
</FONT>

      Attributes include the font face, size, and color. The font face can be specified uniquely, by name, as in Times New Roman, Palatino, Arial, Helvetica, etc, or, by generic name: serif, sans-serif, cursive, fantasy, and monospace. Other tags used in conjunction with the font tags specify weight and style, including bold, italics, superscript, etc. For example, an italicized serif font colored dodgerblue:

<FONT FACE="serif" COLOR="dodgerblue"><I>
does this to text
</I></FONT>

      The browser can use any font available on the client system. The challenge of formatting fonts is that different client systems have different sets of fonts. Three techniques are used to get around this problem.
  1. Limit your use of unusual fonts to a few headings and titles. If possible, present these as images rather than fonts. Your images will look similar on any system, but your fonts may not.
  2. Specify a family of fonts rather than just one font. This gives you the opportunity to get your most desirable font on client systems that have that font, and get an acceptable substitute on those that don`t.
  3. Use embedded fonts. This is an advanced topic, not covered in this text, but if you are in need of a specialized font, it's worth looking into. Embedded fonts are downloaded, like image files, as part of your page.
Keep in mind that most of the time it's not the font you want your viewers to notice, it's the message the font conveys.
    5.6   Formatting Text
 
   
HTML 3
  • Paragraphs
  • Headings
  • Lists
  • Blocks
  • Rules
  • Marquees
      HTML tags give you the opportunity to format a variety of text arrangements.

- Paragraphs -- Headings -- Lists -- Blocks -- Rules -- Marquees -
Try them all, then pick what works best for your application.
 
    5.7   Creating Links
 
   
HTML 4
      A link is a connection from an item that appears in your page to another page in the network you are connected to. The three essential parts of a link are the URL, or address, of the page you want to link, the item, text or image, that will be seen in your page, and the HTML anchor tag that binds the URL to the item.
      A URL can be relative or absolute. A URL with only the directory and file specified is considered relative to the source file of the page. For example, if the page
http://www.mydomain.tld/library/thisfile.htm
is accessed by your browser, a link in this file specified by the relative URL in the hypertext reference (HREF) attribute of an anchor (A) tag:

<A HREF="../faq/sometopic.htm">item</A>

is equivalent to referencing the absolute URL
http://www.mydomain.tld/faq/sometopic.htm

      Links within your site should be relative. Using relative URLs allows you to develop your site in one place, then move it to another when you are ready to publish, without having to change all the URLs that connect the elements of your site. Links to other sites will generally have to be absolute, and therefore unaffected by moving your site from one location to another.
      If you are unfamiliar with directory tree structures and naming files, see Appendix VI: File Names for more information.
    5.8   Adding Images
 
   
HTML 5
This image is titled: On the Lake
On the Lake
      Images can be presented in the foreground or the background. As you implement your site, it is important to keep in mind that background images do not print with the rest of the page. Image formats used on the web are .jpg (or .jpeg) and .gif (or .giff). A more complete discussion of images is included in the chapter on Page Graphics.
      The "On the Lake" image is a typical picture image. The icon at the top left of the page is also a typical picture image. Pictures are often .jpg format files. Of course, images used in a page layout are not just pictures. This page uses images in a variety of ways. The Book Title font was converted to an image because this font may not be available on your system. This is often done for text that is part of the style of the page. These foreground images are large enough to interrupt the flow of text. But others, like this image , fit within a line of text.
      Background images are usually small, because they tile. The background image creating the wallpaper behind the "On the Lake" picture, above, is this small, white transparent .gif image on a light green background. The background image on the "paper", the faded margin, is also a transparent .gif. Even the Menu and See-This-Page buttons in the tutorial page above use background images.
      An image is specified by giving its URL. As with links, an image URL can be relative or absolute. A URL with only the directory and file specified is considered relative to the source file of the page. For example, if the page
http://www.mydomain.tld/library/thisfile.htm
is accessed by your browser, an image in this file specified by the relative URL in the source (SRC) attribute of the image (IMG) tag:

<IMG SRC="images/someimage.jpg">

is equivalent to accessing the source in the absolute URL
http://www.mydomain.tld/library/images/someimage.jpg

      Using relative URLs allows you to develop your site in one place, then move it to another when you are ready to publish, without having to change all the URLs that connect your images. If you are including an image that is to remain published on another site, use an absolute URL.
    5.9   Using Tables
 
   
HTML 6
Using Tables
1: Tabulate Page Content
2: Frame Page Elements
3: Invisibly Arrange Elements
      Tables consist of cells arrayed in rows and columns. A variety of uses for tables are demonstrated in this chapter. The "Using Tables" figure is a table that tabulates page content, the "On the Lake" image above is framed by tables, and another table arranges the framed image and its title. Mouseover these tables to see the cell borders.
      Attributes offer a variety of options in designing tables. These include the border, cellspacing, and cellpadding attributes. Background and font features for individual cells can also be formatted.
      The outer BORDER surrounds the table. If borders are non-zero, an inner border outlines the cells. The space between the outer and inner borders is the CELLSPACING. This attribute also separates cells from each other. The CELLPADDING attribute separates the cell content from its border. The table below has three cells, each containing part of an image. Explore the relationship of attributes in this table:

TABLE BORDER= 0 CELLSPACING= 0 CELLPADDING= 0

 


      Tables have two features that make them especially useful for arranging elements on a page. Although the content of cells may vary, table cells are always located in the same relation to each other. And, tables can be nested. For example, the "On the Lake" image is nested within an inner frame table, nested within an outer frame table, then nested within the table used to arrange the image and the title within the surrounding text. Because complicated tables with invisible borders can be hard to keep track of during development, it is a common practice to give the BORDER a width of 1 while the table is being developed, then change the border to 0 when the table is ready to publish.
    5.10   Using Frames
 
   
HTML 7
      Frames are used to divide a window into separate areas that can be loaded with different HTML pages (documents). Each frame definition specifies the source URL of the file to be loaded into its frame. There are two kinds of frames. The inline frames are placed within a page by the <IFRAME> tag. The set frames fill the window, and are arranged in a special HTML file containing only the <FRAMESET> and <FRAME> tags. When the frameset file is loaded, the frames are made according to its specifications, then the separate source documents are loaded into each frame.
      Frames are useful for keeping one area of the screen constant, while changing another. For example, you could put a row of buttons on the top or bottom of the window, or a menu at the side, then make the rest of the window another frame, a target for each page you load as you go through the menu of options.
    5.11   HTML Standards
      From its inception, the use and capacity of HTML expanded. As a result, managing complex sites became unwieldy, but solutions were found, and the language evolved. Sometimes different developers found different solutions. The World Wide Web Consortium (W3C) convened to ensure the universality of the WWW languages, standards were made, and developers adjusted their implementations to these standards. Where once an <HTML> and a .html was all a page needed to be properly identified, now your page should also have a <!doctype> statement.
      HTML belongs to a family of markup languages that all have one thing in common, they include the content and markup instructions together in plain text files. The Standard Generalized Markup Language (SGML) is the "parent" language that is used to define markup languages. This language uses Document Type Definitions (DTDs) to specify language features. The <!doctype> statement is an SGML tag that references a specific DTD. If this statement appears in the first line of your HTML file, your browser will know which DTD you want to use to format your page.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
      Page Source

</HTML>

If you don't use a doctype statement, your html will most likely be formatted in the current standard. This standard may change over time. The doctype statement assures that your page will always be formatted in the standard specified. The current standards are:

HTML 4.01 defaults to the strict standard
HTML 4.01 Strict
strict
 
adheres to the current standard
HTML 4.01 Transitional
loose
 
also includes deprecated features
HTML 4.01 Frameset
frameset
 
is used in frameset files

    5.12   HTML Deprecation
      In the context of rapid evolution, the need for backward compatibility has made web development difficult. In the end, something has to give, and one of these somethings is embodied in the deprecation, and eventual loss of support, of parts of the HTML language. Because STYLE has solved many site development and maintainence problems, use of STYLE rules is now preferred to the use of HTML attribute assignments where possible. Learning STYLE after you have learned HTML is like learning to drive a car with an automatic transmission after you have learned to drive with a stick shift. It will make you smile!
    5.13   References
1 Apple: Internet and Web
http://developer.apple.com/internet/

2 : Web Content
http://developer.apple.com/internet/webcontent/index.html

3 HTML Writers Guild
http://www.hwg.org/

4 Microsoft Developers Network Library
http://msdn2.microsoft.com/en-us/library/default.aspx

5 : HTML and DHTML Overviews and Tutorials
http://msdn2.microsoft.com/en-us/library/ms537623(vs.85).aspx

6 : HTML Objects
http://msdn2.microsoft.com/en-us/library/default.aspx

7 Microsoft Product Support
http://support.microsoft.com/

8 : List of Default Fonts Included in Windows 98
http://support.microsoft.com/default.aspx?scid=kb;en-us;195708

9 O'Reilly Network Safari Bookshelf
http://safari.oreilly.com

10 : HTML Pocket Reference, 2nd Edition
http://safari.oreilly.com/0596002963

11 World Wide Web Consortium
http://www.w3.org

12 : Character entity references in HTML 4
http://www.w3.org/TR/REC-html40/sgml/entities.html#entities

13 : Getting started with HTML
http://www.w3.org/MarkUp/Guide/

14 : Recommended DTDs to use in your Web document
http://www.w3.org/QA/2002/04/valid-dtd-list.html

15 : The global structure of an HTML document
http://www.w3.org/TR/REC-html40/struct/global.html

All Contents © 2008 Aurora Isaac. All Rights Reserved. Legal Notices.
Previous ChapterTable of ContentsNext Chapter