anantamu.com
If you are running Windows, start Notepad.
If you are on a Mac, start SimpleText.
In OSX, start TextEdit and change the following preferences:
Open the Format menu and select Plain Text instead of Rich Text.
Then open the Preferences window under the TextEdit menu and select
Ignore rich text commands in HTML files.
Your HTML code may not work correctly if you do not change the preferences above.
<html> <head> <title>Title of page</title> </head> <body> This is my first homepage. <b>This text is bold</b> </body> </html>
Save the file as mypage.htm.
Open your Internet browser and select Open (or Open Page) from the File menu. Click Browse, locate the file mypage.htm, and click Open.
The browser will display the page you created.
The first tag in an HTML document is <html>. This tag tells the browser that the document is an HTML document. The last tag is </html>, which tells the browser that the HTML document has ended.
The text between the <head> and </head> tags is header information. This information is not displayed in the browser window.
The text between the <title> tags is the title of the document. The title is displayed in the browser's title bar.
The text between the <body> tags is the content that will be displayed in the browser.
The text between the <b> and </b> tags is displayed in bold font.
When saving an HTML file, you can use either the .htm or .html extension. In older systems, only three-letter extensions were allowed, which is why .htm was commonly used.
With modern software, it is perfectly safe to use the .html extension.
HTML files can be edited using WYSIWYG (What You See Is What You Get) editors such as FrontPage or Dreamweaver.
However, to become a skilled web developer, it is recommended to use a plain text editor to learn basic HTML.
HTML documents are text files made up of HTML elements. HTML elements are defined using HTML tags.
HTML tags are used to define and structure HTML elements in a document.
Consider the following HTML example:
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
This is an HTML element:
<b>This text is bold</b>
The HTML element starts with a start tag <b>.
The content of the HTML element is This text is bold.
The HTML element ends with an end tag </b>.
The purpose of the <b> tag is to define text that should be displayed in bold.
This is also an HTML element:
<body>
This is my first homepage. <b>This text is bold</b>
</body>
This HTML element starts with the <body> tag and ends with the </body> tag. The purpose of the <body> tag is to define the body of the HTML document.
HTML tags are not case sensitive; <B> means the same as <b>. However, modern web standards recommend using lowercase tags.
The World Wide Web Consortium (W3C) recommends lowercase tags in HTML 4, and XHTML requires lowercase tags.
The most important HTML tags define headings, paragraphs, and line breaks. The best way to learn HTML is by working with examples.
Headings are defined using the <h1> to <h6> tags.
<h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3> <h4>This is a heading</h4> <h5>This is a heading</h5> <h6>This is a heading</h6>
HTML automatically adds extra space before and after headings.
Paragraphs are defined using the <p> tag.
<p>This is a paragraph</p> <p>This is another paragraph</p>
HTML automatically adds extra space before and after paragraphs.
Paragraphs can sometimes be written without closing tags, like this:
<p>This is a paragraph <p>This is another paragraph
The example above may work in most browsers, but you should not rely on it. Future versions of HTML will not allow skipping end tags.
Closing all HTML elements with an end tag is a future-proof way of writing HTML. It also makes code easier to read and understand.
The <br> tag is used when you want to break a line without starting a new paragraph. It forces a line break wherever it is placed.
<p>This <br> is a para<br>graph with line breaks</p>
The <br> tag is an empty tag. It has no closing tag like </br>.
You may also see the line break written as <br />. This format follows XHTML rules where all elements must be closed.
Using <br /> is accepted by both HTML and XML and is future-proof.
Comments are used to insert notes inside HTML code. Comments are ignored by the browser and are helpful for explaining code.
<!-- This is a comment -->
Note: An exclamation mark is required after the opening bracket, but not before the closing bracket.
HTML text may look different in different browsers and screen sizes. Text automatically adjusts when the browser window is resized.
Extra spaces and new lines in HTML count as a single space. Do not use empty paragraphs to create space.
Use the <br> tag for line breaks and the <hr> tag to separate sections.
<html> <body> <p>The hr tag defines a horizontal rule:</p> <hr> <p>This is a paragraph</p> <hr> <p>This is a paragraph</p> <hr> <p>This is a paragraph</p> </body> </html>
| Tag | Description |
|---|---|
| <html> | Defines an HTML document |
| <body> | Defines the document body |
| <h1> to <h6> | Defines headings |
| <p> | Defines a paragraph |
| <br> | Inserts a line break |
| <hr> | Defines a horizontal rule |
| <!-- --> | Defines a comment |
Attributes provide additional information about an HTML element.
HTML tags can have attributes. Attributes provide additional information about an HTML element.
The <h1> tag defines a heading.
<h1 align="center">Center aligned heading</h1>
<h1 align="center"> has additional information about the alignment.
The <body> tag defines the document body.
<body bgcolor="yellow">
This demonstrates a background color.
The <table> tag defines an HTML table.
<table border="1"> has additional information about the border around the table.
| Sample Cell | Sample Cell |
HTML attributes are not case sensitive, but W3C recommends using lowercase. XHTML strictly requires lowercase attributes.
Attribute values must be enclosed in quotes.
name='John "ShotGun" Nelson'
<html> <body> <b>This text is bold</b> <br> <strong> This text is strong </strong> <br> <big> This text is big </big> <br> <em> This text is emphasized </em> <br> <i> This text is italic </i> <br> <small> This text is small </small> <br> This text contains <sub> subscript </sub> <br> This text contains <sup> superscript </sup> </body> </html>This text is bold
The <pre> tag is useful for displaying computer code:
<pre> for i = 1 to 10 print i next i </pre> <html> <body>This is
preformatted text.
It preserves both spaces
and line breaks.
The pre tag is good for displaying computer code:
for i = 1 to 10
print i
next i
<html> <body>Computer code
Note: These tags are often used to display computer/programming code.
</body> </html>Computer codeNote: These tags are often used to display computer/programming code.
Donald Duck
BOX 555
Disneyland
USA
Abbrevation Tag:
<html> <body> <abbr title="United Nations">UN</abbr> <br> <acronym title="World Wide Web">WWW</acronym> <p>The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation.</p> <p>This only works for the acronym element in IE 5.</p> <p>This works for both the abbr and acronym element in Netscape 6.2.</p> </body> </html>UN
WWW
The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation.
This only works for the acronym element in IE 5.
This works for both the abbr and acronym element in Netscape 6.2.
If your browser supports bi-directional override (bdo), the next line will be written from the right to the left (rtl):
Here is some Hebrew text
<html>
<body>
Here comes a long quotation:
<blockquote>
This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation.
</blockquote>
Here comes a short quotation:
<q>
This is a short quotation
</q>
<p>
With the block quote element, the browser inserts line breaks and margins, but the q element does not render as anything special.
</p>
</body>
</html>
Here comes a long quotation:
This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation.
Here comes a short quotation:
This is a short quotation
With the block quote element, the browser inserts line breaks and margins, but the q element does not render as anything special.
<html>
<body>
<p>
a dozen is
<del>twenty</del>
<ins>twelve</ins>
pieces
</p>
<p>
Most browsers will overstrike deleted text and underline inserted text.
</p>
<p>
Some older browsers will display deleted or inserted text as plain text.
</p>
</body>
</html>
A dozen is
twenty
twelve
pieces
Most browsers will overstrike deleted text and underline inserted text.
Some older browsers will display deleted or inserted text as plain text.
Have you ever seen a Web page and wondered "Hey! How did they do that?"
To find out, click the View option in your browser's toolbar and select Source or Page Source. This will open a window that shows you the HTML code of the page.
Some characters like the < character have a special meaning in HTML and cannot be used directly.
To display a less than sign (<) in HTML, we must use a character entity like < or <.
A character entity has three parts:
Entities are case sensitive.
HTML normally removes extra spaces. To add extra spaces, use the non-breaking space entity:
Example: Hello World
| Result | Description | Entity Name | Entity Number |
|---|---|---|---|
| Non-breaking space | |   | |
| < | Less than | < | < |
| > | Greater than | > | > |
| & | Ampersand | & | & |
| " | Quotation mark | " | " |
Some Other Commonly Used Character Entities:
Result Description Entity Name Entity Number
¢ cent ¢ ¢
£ pound £ £
¥ yen ¥ ¥
€ euro € €
§ section § §
© copyright © ©
® registered trademark ® ®
× multiplication × ×
÷ division ÷ ÷
HTML uses a hyperlink to link to another document on the Web.
The Anchor Tag and the Href Attribute
HTML uses the <a> (anchor) tag to create a link to another document.
An anchor can point to any resource on the Web: an HTML page, an image, a sound file, a movie, etc.
The syntax of creating an anchor:
<a href="url">Text to be displayed</a>
The <a> tag is used to create an anchor to link from, the href attribute is used to address the document to link to, and the words between the open and close of the anchor tag will be displayed as a hyperlink.
This anchor defines a link to anantamu:
<a href="http://www.anantamu.com/">Visit anantamu!</a>
The line above will look like this in a browser:
Visit anantamu!With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window:
<a href="http://www.anantamu.com/" target="_blank">Visit anantamu!</a>
The line above will look like this in a browser:
Visit anantamu!The name attribute is used to create a named anchor. When using named anchors we can create links that jump directly to a specific section on a page, instead of making the user scroll.
Syntax of a named anchor:
<a name="label">Text to be displayed</a>
The name of the anchor can be any text you care to use. Below defines a named anchor:
<a name="tips">Useful Tips Section</a>
You should notice that a named anchor is not displayed in a special way.
To link directly to the "tips" section from another page, add a # sign and the name of the anchor to the end of a URL:
<a href="http://www.anantamu.com/html_links.asp#tips">
Jump to the Useful Tips Section</a>
From within the same file, you can jump to the "tips" section using:
<a href="#tips">Jump to the Useful Tips Section</a>
Jump to the Useful Tips Section
Here is the content of the Useful Tips Section. You jumped directly here using the named anchor link above!
Always add a trailing slash to subfolder references. If you link like this:
href="http://www.anantamu.com/html", the browser may generate two HTTP requests because the server will add a slash automatically, creating a new request like this:
href="http://www.anantamu.com/html/".
Named anchors are often used to create a "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.
If a browser cannot find a named anchor that has been specified, it goes to the top of the document. No error occurs.
| Tag | Description |
|---|---|
| <a> | Defines an anchor |
With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others.
Disadvantages of using frames:
Example: A frameset with two columns. The first column is set to 25% of the width of the browser window. The second column is set to 75% of the width of the browser window. The HTML document "frame_a.htm" is put into the first column, and "frame_b.htm" into the second column:
<frameset cols="25%,75%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
</frameset>
Notes:
cols="200,500".cols="25%,*".noresize="noresize" to the <frame> tag.| Tag | Description |
|---|---|
| <frameset> | Defines a set of frames |
| <frame> | Defines a sub window (a frame) |
| <noframes> | Defines a noframe section for browsers that do not handle frames |
| <iframe> | Defines an inline sub window (frame) |
Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stand for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc.
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 | row 2, cell 2 |
How it looks in a browser:
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 | row 2, cell 2 |
The border attribute specifies whether the table should have borders. You can set the value of the border in pixels, for example <table border="2"> for thicker borders.
If you do not specify a border attribute, the table will be displayed without any borders. Sometimes this can be useful, but most of the time, you want the borders to show.
To display a table with borders, you will have to use the border attribute:
| Row 1, cell 1 | Row 1, cell 2 |
Headings in a table are defined with the <th> tag.
| Heading | Another Heading |
|---|---|
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 | row 2, cell 2 |
How it looks in a browser:
| Heading | Another Heading |
|---|---|
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 | row 2, cell 2 |
Table cells with no content are not displayed very well in most browsers.
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 |
How it looks in a browser:
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 |
Note that the borders around the empty table cell are missing (NB! Mozilla Firefox displays the border).
To avoid this, add a non-breaking space ( ) to empty data cells, to make the borders visible:
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 |
How it looks in a browser:
| row 1, cell 1 | row 1, cell 2 |
| row 2, cell 1 |
The <thead>, <tbody> and <tfoot> elements are seldom used, because of bad browser support. Expect this to change in future versions of XHTML. If you have Internet Explorer 5.0 or newer, you can view a working example in our XML tutorial.
An unordered list is a list of items. The list items are marked with bullets.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
An ordered list is a list of items. The list items are marked with numbers.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks, images, links, other lists, etc.
<form>
<input>
<input>
</form>
A form is an area that can contain form elements. Form elements allow the user to enter information (like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc.). A form is defined with the <form> tag.
<form>
First name:
<input type="text" name="firstname">
<br>
Last name:
<input type="text" name="lastname">
</form>
Text fields are used when you want the user to type letters, numbers, etc. in a form. By default, most browsers display text fields with a width of 20 characters.
<form>
<input type="radio" name="sex" value="male"> Male
<br>
<input type="radio" name="sex" value="female"> Female
</form>
Note: Only one option can be selected at a time.
<form>
I have a bike:
<input type="checkbox" name="vehicle" value="Bike">
<br>
I have a car:
<input type="checkbox" name="vehicle" value="Car">
<br>
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane">
</form>
Note: Multiple options can be selected at the same time.
<form name="input" action="html_form_action.asp" method="get">
Username:
<input type="text" name="user">
<input type="submit" value="Submit">
</form>
If you type some characters in the text field above and click the "Submit" button, your input will be sent to a page called html_form_action.asp. That page can then display or process the received input.
| Tag | Description |
|---|---|
| <form> | Defines a form for user input |
| <input> | Defines an input field |
| <textarea> | Defines a text-area (a multi-line text input control) |
| <label> | Defines a label to a control |
| <fieldset> | Defines a fieldset |
| <legend> | Defines a caption for a fieldset |
| <select> | Defines a selectable list (a drop-down box) |
| <optgroup> | Defines an option group |
| <option> | Defines an option in the drop-down box |
| <button> | Defines a push button |
| <isindex> | Deprecated. Use <input> instead |
In HTML, images are defined with the <img> tag.
The <img> tag is empty, which means that it contains attributes only and has no closing tag.
To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display on your page.
The syntax of defining an image:
<img src="url">
Example: An image named "boat.gif" located in the directory "images" on "www.anantamu.com" has the URL:
http://www.anantamu.com/images/boat.gif
The browser puts the image where the <img> tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph.
The alt attribute is used to define an "alternate text" for an image. The value of the alt attribute is an author-defined text:
Example:
<img src="boat.gif" alt="Big Boat">
The "alt" attribute tells the reader what he or she is missing on a page if the browser can't load images. The browser will then display the alternate text instead of the image. It is a good practice to include the alt attribute for each image on a page, to improve the display and usefulness of your document for people who have text-only browsers.
Example image with alt text:
If an HTML file contains ten images, eleven files are required to display the page correctly. Loading images takes time, so my best advice is: Use images carefully.
| Tag | Description |
|---|---|
| <img> | Defines an image |
| <map> | Defines an image map |
| <area> | Defines a clickable area inside an image map |
The <body> tag has two attributes where you can specify backgrounds. The background can be a color or an image.
The bgcolor attribute specifies a background-color for an HTML page. The value of this attribute can be a hexadecimal number, an RGB value, or a color name:
<body bgcolor="#000000"><body bgcolor="rgb(0,0,0)"><body bgcolor="black">The lines above all set the background-color to black.
The background attribute specifies a background-image for an HTML page. The value of this attribute is the URL of the image you want to use. If the image is smaller than the browser window, the image will repeat itself until it fills the entire browser window.
<body background="clouds.gif"><body background="http://www.anantamu.com/clouds.gif">The URL can be relative (as in the first line above) or absolute (as in the second line above).
If you want to use a background image, you should keep in mind:
The bgcolor, background, and the text attributes in the <body> tag are deprecated in the latest versions of HTML (HTML 4 and XHTML). The World Wide Web Consortium (W3C) has removed these attributes from its recommendations.
Style sheets (CSS) should be used instead (to define the layout and display properties of HTML elements).
HTML colors can be defined as a hexadecimal notation for the combination of Red, Green, and Blue color values (RGB).
The lowest value that can be given to one light source is 0 (hex #00) and the highest value is 255 (hex #FF).
The table below shows the result of combining Red, Green, and Blue light sources:
| Red | Green | Blue | Result |
|---|---|---|---|
| #FF0000 | #00FF00 | #0000FF | Combination of RGB |
| Color | Color HEX | Color RGB |
|---|---|---|
| #000000 | rgb(0,0,0) | |
| #FF0000 | rgb(255,0,0) | |
| #00FF00 | rgb(0,255,0) | |
| #0000FF | rgb(0,0,255) | |
| #FFFF00 | rgb(255,255,0) | |
| #00FFFF | rgb(0,255,255) | |
| #FF00FF | rgb(255,0,255) | |
| #C0C0C0 | rgb(192,192,192) | |
| #FFFFFF | rgb(255,255,255) |
The 16 W3C standard color names are:
aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow
A collection of nearly 150 color names are supported by all major browsers.
View the cross-browser color names
Some years ago, when most computers only supported 256 different colors, a list of 216 Web Safe Colors was suggested as a Web standard. The reason for this was that the Microsoft and Mac operating systems used 40 different "reserved" fixed system colors (about 20 each).
We are not sure how important this is now, since most computers today have the ability to display millions of different colors, but the choice is left to you.
The 216 cross-browser color palette was created to ensure that all computers would display the colors correctly when running a 256 color palette:
HTML colors are defined using a hexadecimal notation for the combination of Red, Green, and Blue color values (RGB). The lowest value that can be given to one of the light sources is 0 (hex #00). The highest value is 255 (hex #FF).
If you turn off the Red light completely, there are 65536 different combinations of Green and Blue (256 × 256) to experiment with.
By setting the Red parameter to its maximum value, there are still 65536 combinations of Green and Blue.
Combining Red, Green, and Blue values from 0 to 255 produces over 16 million colors (256 × 256 × 256).
Most modern monitors can display at least 16384 colors.
| Color | HEX | RGB |
|---|---|---|
| #000000 | rgb(0,0,0) | |
| #400000 | rgb(64,0,0) | |
| #800000 | rgb(128,0,0) | |
| #C00000 | rgb(192,0,0) | |
| #FF0000 | rgb(255,0,0) |
| Color | RGB | HEX |
|---|---|---|
| rgb(0,0,0) | #000000 | |
| rgb(64,64,64) | #404040 | |
| rgb(128,128,128) | #808080 | |
| rgb(192,192,192) | #C0C0C0 | |
| rgb(255,255,255) | #FFFFFF |
| Color Name | HEX | Preview |
|---|---|---|
| Red | #FF0000 | |
| Green | #008000 | |
| Blue | #0000FF | |
| Black | #000000 | |
| White | #FFFFFF | |
| Yellow | #FFFF00 | |
| Silver | #C0C0C0 | |
| Aqua | #00FFFF | |
| Fuchsia | #FF00FF |
W3C recommends only 16 standard color names. Other colors should be defined using HEX or RGB values.
HTML Quick List from anantamu. Print it, fold it, and put it in your pocket.
<html>
<head>
<title>Document name goes here</title>
</head>
<body>
Visible text goes here
</body>
</html>
<h1>Largest Heading</h1>
<h2>. . .</h2>
<h3>. . .</h3>
<h4>. . .</h4>
<h5>. . .</h5>
<h6>Smallest Heading</h6>
<p>This is a paragraph</p>
<br> (line break)
<hr> (horizontal rule)
<pre>This text is preformatted</pre>
<em>This text is emphasized</em>
<strong>This text is strong</strong>
<code>This is some computer code</code>
<b>This text is bold</b>
<i>This text is italic</i>
<a href="http://www.example.com/">This is a Link</a>
<a href="http://www.example.com/"><img src="URL" alt="Alternate Text"></a>
<a href="mailto:webmaster@example.com">Send e-mail</a>
A named anchor:
<a name="tips">Useful Tips Section</a>
<a href="#tips">Jump to the Useful Tips Section</a>
<ul>
<li>First item</li>
<li>Next item</li>
</ul>
<ol>
<li>First item</li>
<li>Next item</li>
</ol>
<dl>
<dt>First term</dt>
<dd>Definition</dd>
<dt>Next term</dt>
<dd>Definition</dd>
</dl>
<table border="1">
<tr>
<th>someheader</th>
<th>someheader</th>
</tr>
<tr>
<td>sometext</td>
<td>sometext</td>
</tr>
</table>
<frameset cols="25%,75%">
<frame src="page1.htm">
<frame src="page2.htm">
</frameset>
<form action="http://www.example.com/test.asp" method="post/get">
<input type="text" name="lastname" value="Nixon" size="30" maxlength="50">
<input type="password">
<input type="checkbox" checked="checked">
<input type="radio" checked="checked">
<input type="submit">
<input type="reset">
<input type="hidden">
<select>
<option>Apples
<option selected>Bananas
<option>Cherries
</select>
<textarea name="Comment" rows="60" cols="20"></textarea>
</form>
< is the same as <
> is the same as >
© is the same as ©
<!-- This is a comment -->
<blockquote>
Text quoted from some source.
</blockquote>
<address>
Address 1<br>
Address 2<br>
City<br>
</address>
Everywhere on the Web you will find pages that are formatted like newspaper pages using HTML columns.
One very common practice with HTML, is to use HTML tables to format the layout of an HTML page. A part of this page is formatted with two columns, like a newspaper page.
| As you can see on this page, there is a left column and a right column. This text is displayed in the left column. |
An HTML <table> is used to divide a part of this Web page into two columns.
The trick is to use a table without borders, and maybe a little extra cell-padding.
No matter how much text you add to this page, it will stay inside its column borders.
|
| One very common practice with HTML, is to use HTML tables to format the layout of an HTML page. This text is displayed in the left column. |
An HTML <table> is used to divide a part of this Web page into two columns.
The trick is to use a table without borders, and maybe a little extra cell-padding.
|
The <font> tag in HTML is deprecated.
Even if a lot of people are using it, you should try to avoid it, and use styles instead.
With HTML code like this, you can specify both the size and the type of the browser output:
<p>
<font size="2" face="Verdana">
This is a paragraph.
</font>
</p>
<p>
<font size="3" face="Times">
This is another paragraph.
</font>
</p>
| Attribute | Example | Purpose |
|---|---|---|
| size="number" | size="2" | Defines the font size |
| size="+number" | size="+1" | Increases the font size |
| size="-number" | size="-1" | Decreases the font size |
| face="face-name" | face="Times" | Defines the font-name |
| color="color-name" | color="red" | Defines the font color |
The <font> tag is deprecated in the latest versions of HTML.
The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations.
In HTML 4.0 all formatting can be removed from the HTML document and stored in a separate style sheet. This separates presentation from document structure and gives full control over layout.
Do not use presentation attributes inside your HTML tags if you can avoid it. Start using styles! Please read our CSS tutorial to learn about style sheets.
Do not use deprecated tags. Visit our complete HTML 4.01 Reference to see which tags and attributes that are deprecated.
XHTML is the "new" HTML. The most important thing you can do is to start writing valid HTML 4.01.
</p>NOTE: The official HTML 4.01 recommends the use of lower case tags.
HTML 4.01 Strict DTD:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
HTML 4.01 Transitional DTD:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
HTML 4.01 Frameset DTD:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<head>
<style type="text/css">
body { background-color: red; }
p { margin-left: 20px; }
</style>
</head>
<p style="color:red; margin-left:20px">
This is a paragraph
</p>
| Tag | Description |
|---|---|
| <style> | Defines a style definition |
| <link> | Defines a resource reference |
| <div> | Defines a section in a document |
| <span> | Defines a section in a document |
| <font> | Deprecated. Use styles instead |
| <basefont> | Deprecated. Use styles instead |
| <center> | Deprecated. Use styles instead |
The head element contains general information, also called meta-information, about a document.
The elements inside the head element should not be displayed by a browser.
According to the HTML standard, only a few tags are legal inside the head section:
<base>, <link>, <meta>, <title>, <style>, and <script>
Illegal example:
<head>
<p>This is some text</p>
</head>
Most browsers will still display the text even if it is illegal. Should browsers forgive such errors? Some think yes, others think no.
| Tag | Description |
|---|---|
| <head> | Defines information about the document |
| <title> | Defines the document title |
| <base> | Defines a base URL for all links |
| <link> | Defines a resource reference |
| <meta> | Defines meta information |
| <!DOCTYPE> | Defines the document type |
The meta element provides meta-information about the document, mainly for browsers and search engines.
Description meta tag:
<meta name="description"
content="Free Web tutorials on HTML, CSS, XML, and XHTML">
Keywords meta tag:
<meta name="keywords"
content="HTML, DHTML, CSS, XML, XHTML, JavaScript, VBScript">
Due to misuse and spamming, many search engines no longer rely heavily on meta keywords.
<meta name="security" content="low">
Such meta attributes are site-specific and usually have no standard meaning.
scheme://host.domain:port/path/filename
| Scheme | Access |
|---|---|
| file | Local file |
| ftp | FTP server |
| http | Web server |
| news | Newsgroup |
| telnet | Telnet connection |
| WAIS | WAIS server |
<script type="text/javascript">
document.write("Hello World!")
</script>
Output: Hello World!
<script type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
The <noscript> tag defines alternate text if a script is not executed. It is used for browsers that do not support scripts.
JavaScript Example:
<script type="text/javascript">
<!--
document.write("Hello World!")
//-->
</script>
<noscript>Your browser does not support JavaScript!</noscript>
VBScript Example:
<script type="text/vbscript">
<!--
document.write("Hello World!")
'-->
</script>
<noscript>Your browser does not support VBScript!</noscript>
| Tag | Description |
|---|---|
| <script> | Defines a script |
| <noscript> | Defines alternate text if script is not executed |
| <object> | Defines an embedded object |
| <param> | Defines parameters for an object |
| <applet> | Deprecated. Use <object> |
Not valid in base, head, html, meta, param, script, style, and title elements.
| Attribute | Value | Description |
|---|---|---|
| class | class_rule | Class of the element |
| id | id_name | Unique id |
| style | style_definition | Inline CSS |
| title | tooltip_text | Tooltip text |
Not valid in base, br, frame, frameset, hr, iframe, param, and script.
| Attribute | Value | Description |
|---|---|---|
| dir | ltr | rtl | Text direction |
| lang | language_code | Language code |
| Attribute | Value | Description |
|---|---|---|
| accesskey | character | Keyboard shortcut |
| tabindex | number | Tab order |
Only valid in body and frameset elements.
| Attribute | Description |
|---|---|
| onload | Runs when page loads |
| onunload | Runs when page unloads |
| Attribute | Description |
|---|---|
| onchange | Element value changes |
| onsubmit | Form is submitted |
| onreset | Form is reset |
| onselect | Text selected |
| onblur | Element loses focus |
| onfocus | Element gets focus |
| Attribute | Description |
|---|---|
| onkeydown | Key pressed |
| onkeypress | Key pressed & released |
| onkeyup | Key released |
| Attribute | Description |
|---|---|
| onclick | Mouse click |
| ondblclick | Double click |
| onmousedown | Mouse button pressed |
| onmousemove | Mouse moves |
| onmouseout | Mouse leaves element |
| onmouseover | Mouse enters element |
| onmouseup | Mouse button released |
Hexadecimal values are used to display non-standard characters in URLs.
Example: Space = %20
URL encoding is used to convert characters into a format that can be transmitted over the Internet. Characters are replaced with a % followed by their hexadecimal ASCII value.
| ASCII | URL Code | ASCII | URL Code | ASCII | URL Code |
|---|---|---|---|---|---|
| space | %20 | 0 | %30 | A | %41 |
| ! | %21 | 1 | %31 | B | %42 |
| " | %22 | 2 | %32 | C | %43 |
| # | %23 | 3 | %33 | D | %44 |
| ASCII | URL Code | ASCII | URL Code |
|---|---|---|---|
| À | %C0 | à | %E0 |
| Á | %C1 | á | %E1 |
| Â | %C2 | â | %E2 |
| Ã | %C3 | ã | %E3 |
A Personal Web Server allows you to test and host web pages locally before publishing them online.
PWS turns any Windows computer into a Web server. PWS is easy to install and ideal for developing and testing Web applications. PWS has been optimized for workstation use, but has all the requirements of a full Web server. It also runs Active Server Pages (ASP) just like its larger brother IIS.
Note: Microsoft Windows XP Home Edition does not support PWS.
Windows 2000's built-in Web server IIS makes it easy to build large Web applications. Both PWS and IIS include ASP, a server-side scripting standard used to create dynamic and interactive Web applications.
IIS is also available for Windows NT.
HTML is the universal markup language for the Web. HTML lets you format text, add graphics, create links, forms, frames, and tables.
HTML documents are saved as text files and can be read by any browser. The key to HTML is the use of tags, which describe the content.
The next step is to learn XHTML and CSS.
XHTML is the next generation of HTML. HTML 4.01 is the final version of HTML. XHTML is stricter and cleaner and will replace HTML.
| Tag | Description | DTD |
|---|---|---|
| <!--...--> | Defines a comment | STF |
| <!DOCTYPE> | Defines the document type | STF |
| <a> | Defines an anchor | STF |
| <b> | Defines bold text | STF |
| <body> | Defines the body element | STF |
| <br> | Inserts a line break | STF |
| <div> | Defines a section in a document | STF |
| <img> | Defines an image | STF |
| <p> | Defines a paragraph | STF |
| <table> | Defines a table | STF |
Note: HTML tags can have attributes. Core and language attributes are common to most tags.
Not valid in base, head, html, meta, param, script, style, and title elements.
| Attribute | Value | Description |
|---|---|---|
| class | class_rule or style_rule | The class of the element |
| id | id_name | A unique id for the element |
| style | style_definition | An inline style definition |
| title | tooltip_text | Text to display as a tooltip |
Not valid in base, br, frame, frameset, hr, iframe, param, and script elements.
| Attribute | Value | Description |
|---|---|---|
| dir | ltr | rtl | Sets the text direction |
| lang | language_code | Sets the language code |
| Attribute | Value | Description |
|---|---|---|
| accesskey | character | Sets a keyboard shortcut to access an element |
| tabindex | number | Sets the tab order of an element |
HTML 4.0 introduced the ability to trigger browser actions using events, such as running JavaScript when a user clicks an element.
Only valid in body and frameset elements.
| Attribute | Value | Description |
|---|---|---|
| onload | script | Runs when the document loads |
| onunload | script | Runs when the document unloads |
Only valid in form elements.
| Attribute | Value | Description |
|---|---|---|
| onchange | script | Runs when the element value changes |
| onsubmit | script | Runs when the form is submitted |
| onreset | script | Runs when the form is reset |
| onselect | script | Runs when text is selected |
| onblur | script | Runs when the element loses focus |
| onfocus | script | Runs when the element gets focus |
| Attribute | Value | Description |
|---|---|---|
| onkeydown | script | Runs when a key is pressed |
| onkeypress | script | Runs when a key is pressed and released |
| onkeyup | script | Runs when a key is released |
| Attribute | Value | Description |
|---|---|---|
| onclick | script | Runs on mouse click |
| ondblclick | script | Runs on mouse double-click |
| onmousedown | script | Runs when mouse button is pressed |
| onmousemove | script | Runs when mouse pointer moves |
| onmouseover | script | Runs when mouse pointer enters an element |
| onmouseout | script | Runs when mouse pointer leaves an element |
| onmouseup | script | Runs when mouse button is released |