The Hypertext Markup Language (HTML) : Pat Morin COMP 2405
The Hypertext Markup Language (HTML) : Pat Morin COMP 2405
The Hypertext Markup Language (HTML) : Pat Morin COMP 2405
Pat Morin
COMP 2405
Outline
• History of HTML
• Structure of an HTML Document
– DOCTYPE
– HEAD
– BODY
• HTML Tags
– Paragraphs and Headings
– Lists and tables
– Hyperlinks
2
History of HTML
• Hypertext systems were envisioned as early as
1940 by Vannevar Bush and have a rich history
• Tim Berners-Lee and Robert Caillau at CERN, in
1989-1990 developed HTML as a simplification of
SGML
• CERN launched the web in 1991 (HTML+HTTP)
• HTML is now at version 4
3
Versions of HTML
• There are several different version of HTML
– HTML 1.0, 2.0, 3.2, 4.0, 4.01
– XHTML 1.0 and 1.1
4
Structure of an HTML Document
• Every document starts with a DOCTYPE, followed
by an HTML section that contains a head and
body:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>The Hello World Page</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
5
DOCTYPEs
• A list of DOCTYPEs is available here from the
World-Wide-Web Consortium (W3C):
– http://www.w3.org/QA/2002/04/valid-dtd-list.html
6
The Document HEAD
• The HEAD section of the document contains
information about the document as opposed to the
contents of the document
• Minimally, it should include a TITLE
– <title>My Page Title</title>
7
The Document BODY
• The BODY contains the document itself, i.e., what
the user sees
• Any text (also called character data or cdata)
within the body must be contained within some
other tag
8
Paragraphs
• The P tag is used to enclose a paragraph of text
• Paragraphs appear formatted as you would
expected
<p>In the case of a private wedding
announcement cards should be mailed the
following day to all relatives and
acquaintances of both the contracting
parties.
</p>
<h1>Morning Customs</h1>
<p>The morning of the wedding, the ... </p>
10
Lists
• HTML has three kinds of lists:
• Unordered information (bulleted lists)
• Ordered information (numbered lists)
• Definitions (like in a dictionary)
11
Unordered Lists
• The UL tag encloses an unordered list
• The individual list items are enclosed in LI tags
<ul>
<li>Client/server protocols</li>
<li>Web site design</li>
<li>Server-side scripting</li>
<li>Client-side scripting</li>
<li>Mixed-mode scripting</li>
</ul>
12
Ordered Lists
• The OL tag denotes ordered (numbered) lists
• Again, list items are enclosed in LI tags
<ol>
<li>Mix dry ingredients thoroughly.</li>
<li>Pour in wet ingredients.</li>
<li>Mix for 10 minutes.</li>
<li>Bake for one hour at 300 degrees.</li>
</ol>
13
Definition Lists
• Definition lists use the DL tag
• Each item has two parts, the term DT and the
definition DD
<dl>
<dt>Lower cost</dt>
<dd>The new version of this product costs
significantly less than the previous one!</dd>
<dt>Easier to use</dt>
<dd>We've changed the product so that it's much
easier to use!</dd>
17
The A Tag
• So far we know enough to create a simple text
documents
• What about the hyper in hypertext?
• For this we use the A tag
18
The A Tag (Continued)
• The attribute HREF of the A tag specifies the
destination the link will take us to
• This destination can be absolute:
– href=”h ttp://www.google.com/”
– href=”h ttp://www.newgrounds.com/”
• Or relative:
– href=”n otes/index.html”>
– href=”/ teaching/2405/index.html”>
20
Targets and Tags Example
...
<body>
<h1><a name=”c hap1”> Chapter 1</a></h1>
</body>
21
Images
• Images can be added to the document with the
IMG tag
• The SRC attribute specifies the location of the
image data
• The ALT attribute specifies some text to display if
the image can not be displayed
<img src="kafka.jpg" alt="Franz Kafka's Portrait">
22
Line Breaks
• For a quick and dirty line break you can use the BR
tag
• Normally you should avoid this
• Why are you breaking the line?
– For a list of items (or menu): use <ul>
– To shorten a line: let the browser wrap it
– For preformatted text: use the <pre> tag
• Do as I say, not as I do
– Some examples may contain <br> tag to make them shorter
– You should avoid them
23
Summary
• There are many versions of HTML
– You must specify which version using the DOCTYPE tag
24
HTML Formatting
• All of the HTML tags discussed have other
attributes, examples:
– <td align=” right” valign=”t op” bgcolor=” red”>
– <body background=”i mage1.gif” link=”b lue”
text=” red”>
25