This informational resource is designed to teach you everything you need to know so that you can begin building your own customized web pages in standard HTML 4. HTML stands for Hypertext Markup Language and is the standard language that browsers and web servers understand. It was designed to present and format text on screen and does just that.
In order to begin you need to have some HTML tags (tags henceforth) that tell the computer that the page is written in HTML.
Here is an extremely basic web page.
<HTML> <!-- This tells the computers that the page is written in HTML-->
<HEAD> <!-- This is the opening portion of the page that is not seen when displayed -->
</HEAD>
<BODY> <!-- This is the main portion of the page that is seen by the user -->
Welcome!
</BODY>
</HTML>
Notice that <!-- NOTE --> was used. These are known as comment tags. Anything within <!-- and --> will not be processed by the web server in an HTML page. The page above would simply display:
Welcome!
Now let's get into making those web pages more interesting than just a simple message. But first we need to continue our look at some technical aspects of the HTML language and document.
<html>Styles
<head>
<body>
Inline Elements - Font StyleTables
Block-level text elements
Headers
Font - Deprecated
Text Containers
Example - Basic Table, 1 row, 2 cellsLists
Complex Tables
Example of a Complex Table
Example of a Definition ListForms
Example of unordered list
Example of ordered list
Example of nested list
Example of a Complex FormLinktypes
All tags are enclosed in brackets <> and closed with a /tagname i.e. <HTML> </HMTL>
Everything within this tag is part of the HTML document. There are two standard pieces to the document (see below). The tag is closed with </HTML>
The header information for the document including metadata like title, keywords, scripts (see below), and style sheets (see below). Closed with </HEAD> or a preceding <BODY> tag. Below is a list of tags normally used in the Header area:
An example of a complex <HEAD> area of an HTML document.
<HEAD>
<META name="keywords" Content="html,tutorial,overview,css,reference">
<META name="Author" lang="en" content="Christophor Rick">
<TITLE>HTML 4 Overview</TITLE>
<META name="copyright" content="© 2010 Company Name">
</HEAD>
The document body. Everything within the body tag will be rendered by the web server (except for comments, see above). The tag has attributes that are defined for the whole page. The tag is closed with </body>
Attributes of the Body Tag: Attributes define particular parts within a tag. These will be applied to the entire page but can be overridden by using some text-specific tags later.
Here is an example of a BODY tag with attributes defined:
<BODY bgcolor="Black" background="/background.jpg" text="White" link="Blue" vlink="#00ff00" alink="Orange">
Alternately, this could all be done with a Cascading Style Sheet (CSS) or in the <HEAD> tag like so:
<HEAD>
<STYLE>
body
</STYLE>
</HEAD>
See Styles for inline and style sheet usage.
With HTML 4 also came style sheets and cascading style sheets. The difference between the two is that one can be applied to a single page while the latter is a separate file and can be included and applied to all pages on a given website. Below are examples of what both an inline style sheet and an external CSS file may look like.
As stated above, the <HEAD> tag of an HTML document is able to hold style information, but you can also put in inline within the <BODY> tag as well.
An inline style is formatted slightly differently than a style sheet. For example, if we want to style a table with an inline style it might look like this:
<table style=" width: 100%; height: 300px; border: 1px;">...</table>
That inline style would only be applied to that single table. Notice that the entire style is included in a style attribute within the <table> tag itself.
However, the power of styles and CSS come in when you use it in the header or in a different file. This allows styles to be applied to all instances of HTML elements.
Here is an example of an external cascading style sheet. Comments, unlike HTML are enclosed in /* and */
body
input, textarea, select
a:active
a:link
a:visited
The format for CSS styles is
Selector is the HTML element to be styled and the property is the attribute. There must be a colon : between the property and value and each pair must be closed with a semi-colon ; All of the attributes for a specific Selector must be enclosed in bracket
There are numerous resource on the web, in print and software that are available to teach, assist and validate CSS.
Some elements and tags were created to serve a specific purpose that does not deal with the display or arrangement of text but include other parts necessary or useful in an HTML document.
<A> - Anchor, defines an interactive link to a portion of the same document or to other documents or files. Must be one of a specific set of linktypes Attributes include: NAME, CHARSET, ACCESSKEY, TABINDEX, ONFOCUS, ONBLUR, TARGET and several specific attributes below:
Examples
A link within the same document:
<a name=Top>Top</a>
<a href="#top">Back to Top</a>
A link to another document:
<A HREF="example.html">Example</A>
A link to compose an email in the default email program:
<A HREF="mailto:example@domain.com" TITLE="Feedback on The Big HTML 4 How-To">example@domain.com</A>
<applet> - Defines the parameters and location of a Java Applet. Attributes include: WIDTH, HEIGHT, NAME, ALT, ALIGN and
<BDO> - Defines an override to the standard bi-directional algorithm that defines left-to-right and right-to-left for certain languages. More information at W3C.
<BR>- A line break, like a carriage return in word processors. Example: <p>This text is<br>broken</p>
This text is
broken
<IMG> - Defines the placement and display of an image. Attributes include: SRC, ALT, WIDTH, HEIGHT, USEMAP, ISMAP, NAME and LONGDESC which is a longer description of the image than the ALT tag provides. Generally supported formats are .gif .jpg and .png
<object> - Defines an object to be included in the document. Generally including video, audio Java and Flash. Attributes include: ARCHIVE, CODEBASE, WIDTH, HEIGHT, NAME, USEMAP, TYPE, TABINDEX and the following
<PARAM> - Provides additional parameters for embedded objects. Attributes include: NAME, VALUE, VALUETYPE (data, ref, object), TYPE and ID. More information at W3C.
<SCRIPT> - Defines a client-side script to be included when the page is loaded. Generally used to include Javascript that is contained in separate files. Attributes include: TYPE, SCR, CHARSET and DEFER which means that the execution of the script can wait after the rest of the document is rendered. More information at W3C.
<SPAN>- A generic inline container used to apply styles to the contents of the span. Used when no other inline element can be used to properly style the contents. Can only contain inline elements. <DIV> is the block-level equivalent.
Now that we have taken a look at the basics of the technical tags for HTML, it 's time to work with some text. Though images, sounds and video can all be displayed on web pages, text is still the most prevalent form of information transmission and so it is still important to know how to make it look good. Styles for text can be directly applied to specific text inline with HTML. Common text decorations include bold, emphasized, italic, strong, big, small, sub and superscript.
<b> - Bold, to give a heavy visual style to a specific piece of text <b>Bold</t> would give you Bold
<strong> - Strong, will also give the appearance of bold but generally refers to the text being given more importance than the surrounding text.
<i> - Italic, will italicize, or give a lean to, some text.
<em> - Emphasis, Also looks like Italic in most browsers but again is meant to impart more importance for some text
<big> - Makes text bigger than the surrounding text Can be nested to produce even bigger text.
<small> - Makes text smaller than the surrounding text. Can be nested to produce even smaller text. <small>Small</small> Small
<sub> - Subscript, to place words lower and smaller than the standard text
<sup> - Superscript, to place words higher and smaller than the standard text.
<u> - Underline, draws a line beneath the text, similar to <ins> but without the implication that the text was inserted.
<code> - Commonly used to show examples of HTML and other programming code. Uses a fixed width (monospace) font (see wikipediafor font list).
<tt> - Teletype Text, this is text that is rendered in a fixed width font.
<kbd> - Keyboard, used when denoting directions and giving commands to type in a keyboard. Uses a Fixed Width Font
<q> - Short Quotation, inserts quotation marks around a piece of text denoting a quote from another source.
<cite> - Citation, shows that you are citing another source. Places the text in Italic. Commonly used for copyright lines on web pages.
<var> - Variable, denotes when you are talking about a computer programming variable. Used for demonstrating programming code, not for actual coding.
<bdo> - Text direction, choices are rtl - right to left meaning the text will display backwards. and ltr - left to right, standard for most languages.
<abbr> - Abbreviation, used to show that some text is an abbreviation.
<acronym> - Acronym, abbreviations spoken like words.
<address> - Address, used to define contact information, generally about the creator of a webpage.
Company XYX
1313 Mockingbird Lane
52010
<blockquote> - Block Quote, shows that the text itself is a long quote from another source. Indents the entire block of text.
Four score and seven years ago our fathers brought forth, upon this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.
<ins> - Inserted, draws a line beneath the text. Used in conjunction with <del> it represents text that was inserted into a document during a correction.
<del> - Strikeout, used when you want to show a correction was made do a piece of text. (Deprecated forms <strike> or <s>)
<pre> - Preformatted, replaced <listing>, <xmp> and <plaintext>. Allows spaces and carriage returns (/n for demonstration) to be preserved when rendering the text.
This is Preformatted
Text.
Headers have their own special set of tags which are based on the size of the header. They are used for showing that a section of sub-section of a document is beginning.
<h1> - Header level 1 - A main section - <h1>Header 1</h1> Header 1
<h2> -Header level 2 - A sub-section of an H1 section - <h2>Header 2</h2> Header 2
<h3> -Header level 3 - A sub-section of an H2 section - <h3>Header 3</h3> Header 3
There are actually 6 levels of headers <h1> to <h6>. They all contain the Align attribute with values: Left, Right, Center and Justify. This moves the header to the specified area of the line it is on. Headers can be styled with Inline styles and CSS (see Style section).
The <font> tag was used to define aspects pertaining to the font that will be displayed on the HTML document when it is rendered. It has been deprecated in HTML 4. Instead it is recommended that you utilize style sheets (below). The font tag contained several attributes which included size, face and color.
There are certain containers that allow you to manage text in HTML 4. These let you create groups of text and then you can apply styles to each one specifically by using a naming convention.
<p> - Paragraph - Groups a piece of text together in a paragraph. Styles can then be applied to entire paragraphs via styles and style sheets. (see example below)
<DIV>- Division, a generic block-level container. It allows styles to be applied to a block of content. Inside of a div can be other block-level elements (like div, span, p) and inline elements (see Text above). Headers are also considered block-level elements. A DIV can have an ID and a class, both of which can have styles applied to them separately. A DIV can also be inside of another block-level element.
Example:
<div id="test"> <!-- test is the name that will be used to apply styles-->
<h1>A Block-level header</h1>
<br> <!-- HTML tag to force a line break-->
<p id="Para1"> Everything in this will be grouped together like a paragraph. No matter how many sentences or words. That is a block-level elements job.</p>
<p ="Para2">This will begin a new paragraph and so this text will be separate from that above</p>
</div>
<center> - A block element that will be centered on the page. It is technically shorthand for <div align=center> Deprecated in place of style sheets. It can contain other block level and inline elements but it is suggested that it not be used.
Tables are used to display multi-dimensional data (arrays) or to organize text into rows and columns. In order for a table to be complete it must have at least one Row and one Cell.
<table> - The opening tag for a table. Attributes can be specified in the tag but are better used in the style sheet. Must be closed with </table>.
Attributes include:
<tr> - Tag for a table row. Used to organize cells into a row. </td> Attributes include:
<td> - Tag for a Table Data cell. Must be closed with </td> Cells are held within rows.
<TABLE>
<TR>
<Td>Text 1</Td>
<Td>Text 2</Td>
</TR>
</table>
Result:
| Text 1 | Text 2 |
Tables can contain more than simple rows of data cells. They can also have specific types of cells including:
<caption> - Table caption, defines a summary or heading for the table. Must be the first element after the <TABLE> tag. Most inline tags can be used within this tag (strong, em, etc)
<col> -Table column, used to define attributes for an entire column in a table. Must be used after <caption> and before the <thead>. Most common usage is with the span attribute to force cells to span multiple columns.
<colgroup> - Column group, allows styles to be applied to groups of columns in a table Must be used after <caption> and before the <thead>. The span attribute defines the number of columns to be included in the group. Other attributes, when used, will be applied to all columns and cells in the group. Attributes - span, width, align, char, charoff, valign.
<thead> - Table Head, used to define a row or rows that are headers for the table. This allows the headers to be printed and displayed on every page of a printed table. Also allows for static headers and a long scrolling table. Not supported by all browsers. Must contain a <TR> (see example below). Attributes include - Align, Char, Charoff, Valign (see above)
<th> - The <THEAD> requires a special tag for the cells in them. This differentiates the cells from standard Data cells <TD> When the table is rendered in a compatible browser it will treat these cells as headers. Attributes include Align, Char, Charoff, Valign, (height, width, bgcolor, nowrap are all deprecated for style sheets)
Attributes
<tbody> - Table body, defines a group of data rows that represent the main information in the table. If <thead> or <tfoot> are used then this tag must also be used. Multiple <tbody> tags can be used in a single table allowing for each to have a style applied to them. Not supported by all browsers.
<tfoot> - Table Footer, used to define a row or rows that are a footer for a table. This allows the footer to be printed and displayed on every page of a printed table. Also allows for static footers and a long scrolling table. Not supported by all browsers.
<TABLE>
<THEAD>
<TR>
<TH ROWSPAN=2>Date</TH>
<TH ROWSPAN=2>Time</TH>
<TH ROWSPAN=2>Name</TH>
<TH ROWSPAN=2>ID Number</TH>
</TR>
</THEAD>
<TBODY>
<TR>
<TD>22-01-2009</TD>
<TD>13:30</TD>
<TD>John Smith</TD>
<TD>123456789</TD>
</TR>
</TBODY>
<TFOOT>
<TR>
<TD COLSPAN=4>
Time listed is for entry into facility.
</TD>
</TR>
</TFOOT>
</TABLE>
| Date | Time | Name | ID Number |
| 22-01-2009 | 01:30:00 PM | John Smith | 123456789 |
Time listed is for entry into facility. |
|||
Without a long table it is difficult to show exactly how these tags function. For more information see the W3C specification
<dir> - Defines a directory list. Must contain <li> elements. Cannot contain block level elements. Deprecated in HTML 4, use <ul>
<dl> - Defines a definition list. Provides a list of words and definitions. May contain multiple definitions for each term and multiple terms for each definition. Must contain a <dt> and a <dd> tag.
<dt> Definition term, the word being defined in a definition list. Cannot contain block level elements. The closing tag </dt> is optional but its omission could create problem.
<dd> Definition description, the definition of the word being defined in a definition list. The closing tag </dd> is optional but its omission could create problem.
<DL>
<DT><A NAME="HTML">HTML</A></DT>
<DD>
<P>
Hypertext Markup Language, a markup language that is used to create documents on the World Wide Web incorporating text, graphics, sound, video, and hyperlinks
</P>
</DD>
</DL>
<menu> Menu list, a single level list. Deprecated in favor of <ul>.
<ul> - Defines an unordered list, which means the items in the list have no specific sequence. Must contain at least one <li> tag. Unordered lists are generally represented by an indent and a bullet before each item. Styles can be applied to change the appearance of the bullets and the list items. Deprecated attributes (use styles now) include type disc | square | circle (bullet style), compact (reduce spacing between lines).
<ol> - Defines an ordered list where the items in the list have a particular sequence (i.e. installation instructions). Must contain at least one <li> tag. Styles can be applied to change the appearance of the numbering/lettering and the list items. Deprecated attributes include type (for numbering/lettering) 1 | a | A | i | I (Roman numerals), start (the number to begin from), compact.
<li> - List item, items in a list. Must be used within a <dir>, <ul> or <ol> tag. When used inside an ordered or unordered list may contain block level elements. May also contain other <ol> or <ul> tags which allows for nesting (see below).
<ul>
<li>List item</li>
<li>List item</li>
</ul>
Results:
<ol>
<li>list item 1</li>
<li>list item 2</li>
</ol>
Results:
<ul>
<li>List item</li>
<li>List item</li>
<li><ol>
<li>list item 1</li>
<li>list item 2</li>
</ol>
</li>
</ul>
Results:
Forms give you a way to create an interactive portion of an HTML document where the viewer can input information that can then be saved or acted upon.
<form> - Defines an interactive form. Should have controls including <input>, <select>, <textarea> and <button>.
Attributes include:
<button> - Defines a button. Three types, a submit, reset or button (for other actions). Can be given a wide range of values including text and images.
Attributes include:
<fieldset> - Defines groups of fields within a form. Multiple fieldsets can be defined in a single form and they can be used. A fieldset must begin with a <legend> tag which will be the title for the form section and can also include an accesskey attribute. After the <legend> the fieldset can then contain block-level and inline elements and a nested fieldset. Within the fieldset there should be at least one form of input element. (see example below)
<input> - Defines a form control for input of data from a distinct list of types. Types include: text, password, checkbox, radio, submit, reset, file, hidden, image and button. (see example below)
Attributes include:
<label> - Defines a label for a form control. Allows for clues and hints for users of non-visual browsers. Attributes - Accesskey, ONFOCUS, ONBLUR and FOR the value of which is the form field name. <LABEL FOR=example ACCESSKEY=U>Example</LABEL>
<select> - Defines a form control which will have a list of options. Will be displayed as a text box where one or more items can be chosen (depending on attributes). Attributes include: NAME, SIZE, DISABLED, ONFOCUS, ONBLUR, ONCHANGE, TABINDEX and MULTIPLE when defined allows for multiple selections by holding down the CTRL key and clicking on items.
<SELECT NAME=Languages MULTIPLE>
<OPTION>English</OPTION>
<OPTION>Spanish</OPTION>
<OPTION>French</OPTION>
<OPTION>Italian</OPTION>
<OPTION>German</OPTION>
</SELECT>
<optgroup> - Defines a group of select options that are organized in groups within a select menu. Must contain at least one <option> tag. Attributes include: LABEL and DISABLED.
<option> - Defines the options within an <optgroup> tag. Attributes include: VALUE, LABEL, DISABLED and SELECTED which, when specified, acts like CHECKED.
<SELECT NAME=OS>
<OPTGROUP LABEL="Windows">
<OPTION LABEL="98">98</OPTION>
<OPTION LABEL="NT">NT</OPTION>
<OPTION LABEL="XP" SELECTED>XP</OPTION>
<OPTION LABEL="Vista">Vista</OPTION>
<OPTION LABEL="7">7</OPTION>
</OPTGROUP>
</SELECT>
<textarea> - Defines a multi-line text area for user input. Attributes include: NAME, DISABLED, READONLY, ACCESSKEY, TABINDEX, ONFOCUS, ONBLUR, ONSELECT, ONCHANGE, ROWS (number of rows high) and COLS (number of columns wide). Initial value of the textarea is given in the tag.
<textarea name=Example rows=5 cols=30>This is the initial value.</textarea>
<FORM METHOD=post ACTION="/cgi-bin/register.cgi" NAME=Registration>
<FIELDSET>
<LEGEND ACCESSKEY=I>Contact Information</LEGEND>
<TABLE>
<TR>
<TD>
<LABEL FOR=name ACCESSKEY=N>Name:</LABEL>
</TD>
<TD>
<INPUT TYPE=text NAME=name ID=name>
</TD>
</TR>
<TR>
<TD>
<LABEL FOR=email ACCESSKEY=E>E-mail Address:</LABEL>
</TD>
<TD>
<INPUT TYPE=text NAME=email ID=email>
</TD>
</TR>
<TR>
<TD>
<LABEL FOR=addr ACCESSKEY=A>Postal Address:</LABEL>
</TD>
<TD>
<TEXTAREA NAME=address ID=addr ROWS=4 COLS=40></TEXTAREA>
</TD>
</TR>
</TABLE>
</FIELDSET>
<P>Which Web languages do you speak?</P>
<SELECT NAME=Languages MULTIPLE>
<OPTION>English</OPTION>
<OPTION>Spanish</OPTION>
<OPTION>French</OPTION>
<OPTION>Italian</OPTION>
<OPTION>German</OPTION>
</SELECT>
<P> Choose your Operating System:</P>
<SELECT NAME=OS>
<OPTGROUP LABEL="Windows">
<OPTION LABEL="98">98</OPTION>
<OPTION LABEL="NT">NT</OPTION>
<OPTION LABEL="XP" SELECTED>XP</OPTION>
<OPTION LABEL="Vista">Vista</OPTION>
<OPTION LABEL="7">7</OPTION>
</OPTGROUP>
</SELECT>
<p>Biography:</P>
<textarea name=Example rows=5 cols=30>Tell us a little about yourself</textarea>
<P>
<INPUT TYPE=submit VALUE="Submit info">
</P>
</FORM>
The currently defined list of linktypes for HTML 4.0 include the following: