Introduction To HTML
Introduction To HTML
Introduction To HTML
LANGUAGE REFERENCES
HyperText Markup Language (HTML) is a markup language designed for the creation of web
pages with hypertext and other information to be displayed in a web browser. HTML is used to
structure information denoting certain text as headings, paragraphs, lists and so on and can
be used to describe, to some degree, the appearance and semantics of a document. HTML's
grammar structure is the HTML DTD that was created using SGML syntax.
Markup Language combines text and extra information about the text. The extra information,
for example about the text's structure or presentation, is expressed using markup, which is
intermingled with the primary text. The best-known markup language in modern use is HTML
(HyperText Markup Language), one of the foundations of the World Wide Web.
Web page or webpage is a resource on the World Wide Web, usually in HTML/XHTML format
with hypertext links to enable navigation from one page or section to another. Varying filename
extensions can be used, such as .htm, .html, or .php to name a few. Web pages often use graphic
files to provide illustration. A web page is displayed using a web browser, which can have a
Graphical User Interface, like Internet Explorer, Mozilla Firefox, or Opera, or can have a Command
Line Interface, like Lynx.
Hypertext is a user interface paradigm for displaying documents which, according to an early
definition (Nelson 1970), "branch or perform on request." The most frequently discussed form of
hypertext document contains automated cross-references to other documents called hyperlinks.
Selecting a hyperlink causes the computer to display the linked document within a very short
period of time.
Web browser is a software application that enables a user to display and interact with text,
images, and other information typically located on a web page at a website on the World Wide
Web or a local area network. Text and images on a web page can contain hyperlinks to other web
pages at the same or different websites. Web browsers allow a user to quickly and easily access
information provided on many web pages at many websites by traversing these links.
Uniform Resource Locator (URL) is a string of characters conforming to a standardized
format, which refers to a resource on the Internet (such as a document or an image) by its
location.
For
example,
the
URL
of
this
page
on
Wikipedia
is
http://en.wikipedia.org/wiki/Uniform_Resource_Locator.
An HTTP URL, commonly called a web address, is usually shown in the address bar of a web
browser.
Standard Generalized Markup Language (SGML) is a metalanguage in which one can define
markup languages for documents. SGML is a descendant of IBM's Generalized Markup Language
(GML), developed in the 1960s by Charles Goldfarb, Edward Mosher and Raymond Lorie (whose
surname initials also happen to be GML). SGML should not be confused with the Geography
Markup Language (GML) developed by the Open GIS Consortium; cf, or the Game Maker scripting
language, GML.
BRIEF HISTORY
Tim Berners-Lee, who pioneered the use of hypertext for sharing information, created the first
web browser, named WorldWideWeb, in 1990 and introduced it to colleagues at CERN in March
1
1991. Since then the development of web browsers has been inseparably intertwined with the
development of the web itself.
The explosion in popularity of the web was triggered by NCSA Mosaic which was a graphical
browser running originally on Unix but soon ported to the Apple Macintosh and Microsoft
Windows platforms. Version 1.0 was released in September 1993, and was dubbed the killer
application of the Internet. Marc Andreessen, who was the leader of the Mosaic team at NCSA,
quit to form a company that would later be known as Netscape Communications Corporation.
NCSA Mosaic was originally designed and programmed for Unix's X Window System by Marc
Andreessen and Eric Bina at NCSA. Development of Mosaic began in December 1992. Version 1.0
was released on April 22, 1993, followed by two maintenance releases during summer 1993
Many HTML elements include attributes in their start tags, defining desired behavior. The end
tag is optional for many elements; in a minimal case, an empty element has no content or end
tag. There are a few elements that are not part of any official DTDs, yet are supported by some
browsers and used by some web pages. Such elements may be ignored or displayed improperly
on browsers not supporting them. Informally, HTML elements are sometimes referred to as "tags"
(an example of synecdoche), though many prefer the term tag strictly in reference to the
semantic structures delimiting the start and end of an element.
HTML BASIC STRUCTURE
HTML The first and last tags in a document should always be the HTML tags. These are the tags
that tell a Web browser where the HTML in your document begins and ends. The absolute
most basic of all possible Web documents is: <HTML>
</HTML>
HEAD. The HEAD tags contain all of the document's header information. When I say "header," I
don't mean what appears at the top of the browser window, but things like the document
title and so on. Speaking of which...
TITLE. This container is placed within the HEAD structure. Between the TITLE tags, you should
have the title of your document. This will appear at the top of the browser's title bar, and
also appears in the history list. Finally, the contents of the TITLE container go into your
bookmark file, if you create a bookmark to a page.
BODY. BODY comes after the HEAD structure. Between the BODY tags, you find all of the stuff
that gets displayed in the browser window. All of the text, the graphics, and links, and so
on -- these things occur between the BODY tags. We'll get to what happens there starting
with the next chapter.
So, putting everything we've covered thus far into one file, we have:
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
BASIC TAGS
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading. <h6> defines
the smallest heading.
<h1>This
<h2>This
<h3>This
<h4>This
<h5>This
<h6>This
is
is
is
is
is
is
a
a
a
a
a
a
heading</h1>
heading</h2>
heading</h3>
heading</h4>
heading</h5>
heading</h6>
HTML automatically adds an extra blank line before and after a heading.
Paragraphs
Paragraphs are defined with the <p> tag.
<p>This is a paragraph</p>
<p>This is another paragraph</p>
HTML automatically adds an extra blank line before and after a paragraph.
Line Breaks
The <br> tag is used when you want to end a line, but don't want to start a new paragraph. The <br>
tag forces a line break wherever you place it.
<p>This <br> is a para<br>graph with line breaks</p>
The <br> tag is an empty tag. It has no closing tag.
Comment Tags
If you want to leave yourself notes in an HTML document, but don't want those notes to show
up in the browser window, you need to use the comment tag. To do that, you would do the
following:
<!-- Hi, I'm a comment. -->
Your note would go where the text Hi, I'm a comment. appears. Yes, you do need an
exclamation point after the opening bracket, but not before the closing bracket. That's the way
the standard is written
Description
<b>
<big>
<em>
<i>
<small>
<strong>
<sub>
<sup>
<ins>
<del>
<s>
<strike>
<u>
Character Entities
Some characters have a special meaning in HTML, like the less than sign (<) that defines the
start of an HTML tag. If we want the browser to actually display these characters we must insert
character entities in the HTML source.
A character entity has three parts: an ampersand (&), an entity name or a # and an entity
number, and finally a semicolon (;).
To display a less than sign in an HTML document we must write: < or <
The advantage of using a name instead of a number is that a name is easier to remember. The
disadvantage is that not all browsers support the newest entity names, while the support for
entity numbers is very good in almost all browsers.
Non-breaking Space
The most common character entity in HTML is the non-breaking space. Normally HTML will
truncate spaces in your text. If you write 10 spaces in your text HTML will remove 9 of them. To
add spaces to your text, use the character entity.
The Most Common Character Entities:
Result
Description
Entity Name
Entity Number
non-breaking space
 
<
less than
<
<
>
greater than
>
>
&
ampersand
&
&
"
quotation mark
"
"
'
apostrophe
'
Result
Description
Entity Name
Entity Number
cent
¢
¢
pound
£
£
yen
¥
¥
section
§
§
copyright
©
©
registered trademark
®
®
multiplication
×
×
division
÷
÷
Attribute
Example
Purpose
Size="number"
size="2"
Size="+number"
size="+1"
size="-number"
size="-1"
face="face-name"
face="Times"
color="color-value"
color="#eeff00"
color="color-name"
color="red"
The <font> tag is deprecated in the latest versions of HTML (HTML 4 and XHTML).
The World Wide Web Consortium (W3C) has removed the <font> tag from its recommendations.
In future versions of HTML, style sheets (CSS) will be used to define the layout and display
properties of HTML elements.
The <img> tag is empty, which means that it contains attributes only and it 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">
The URL points to the location where the image is stored. An image named "boat.gif" located
in the directory "images" on "www.w3schools.com" has the URL:
http://www.w3schools.com/images/boat.gif.
The browser puts the image where the image 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
The alt attribute is used to define an "alternate text" for an image. The value of the alt
attribute is an author-defined text:
Backgrounds
The <body> tag has two attributes where you can specify backgrounds. The background can
be a color or an image.
Bgcolor
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">
Background
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.w3schools.com/clouds.gif">
The URL can be relative (as in the first line above) or absolute (as in the second line above).
Note: If you want to use a background image, you should keep in mind:
Will the background
Will the background
Will the background
Will the background
Will the background
Basic Notes - Useful
image
image
image
image
image
Tips
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).
The name attribute is used to create a named anchor. When using named anchors we can
create links that can jump directly into a specific section on a page, instead of letting the user
scroll around to find what he/she is looking for. Below is the syntax of a named anchor:
Unordered Lists
An unordered list is a list of items. The list items are marked with bullets (typically small black
circles). An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers. An ordered list
starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
9
Definition Lists
A definition list is not a list of items. This is a list of terms and explanation of the terms. A
definition list starts with the <dl> tag. Each definition-list term starts with the <dt> tag. Each
definition-list definition starts with the <dd> tag.
<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.
List Tags
Tag
Description
<ol>
<ul>
<li>
<dl>
<dt>
<dd>
Tables
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 stands 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.
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
Headings in a Table
Headings in a table are defined with the <th> tag.
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
11
Description
<table>
Defines a table
<th>
<tr>
<td>
</table>
13