Académique Documents
Professionnel Documents
Culture Documents
Notes
Unit - III
HTML is the predominant markup language for web pages. HTML is the basic building-blocks
of web pages.
HTML is short for HyperText Markup Language.
Hypertext is simply a piece of text that works as a link.
Markup Language is a way of writing layout information within documents.
Basically an HTML document is a plain text file that contains text and nothing else.
HTML is written in the form of HTML elements consisting of tags, enclosed in angle brackets
(like <html>), within the web page content. HTML tags normally come in pairs like <h1> and
</h1>. The first tag in a pair is the start tag, the second tag is the end tag (they are also called
opening tags and closing tags).
The purpose of a web browser is to read HTML documents and compose them into visual or
audible web pages. The browser does not display the HTML tags, but uses the tags to interpret
the content of the page.When a browser opens an HTML file, the browser will look for HTML
codes in the text and use them to change the layout, insert images, or create links to other pages.
Since HTML documents are just text files they can be written in even the simplest text editor.
A more popular choice is to use a special HTML editor - maybe even one that puts focus on the
visual result rather than the codes - a so-called WYSIWYG editor ("What You See Is What You
Get").
Some of the most popular HTML editors, such as FrontPage or Dreamweaver will let you create
pages more or less as you write documents in Word or whatever text editor you're using.
A web page is an "HTML Document". This is a file format which usually uses the extension
".html" or ".htm". For example, if you use Microsoft Word, you will usually save your files with
the extension ".doc". However you can also save your files with many other extensions such as
".txt", ".wps" etc. Amongst the options is ".html".
HTML documents are actually just plain text, but contain snippets of code which carry vital
information about how the page should be displayed. You can create such a document using any
text editor - even a very simple one like Windows Notepad. In fact many web designers prefer to
use simple text editors.
This is what a very simple HTML document looks like:
<html>
<head>
<title>A Simple Web Page</title>
</head>
<body>
This is about as simple as a web page can get.
</body>
</html>
To view an HTML document, you must use a browser (or similar software). The browser opens
the HTML document in the background and "decodes" it before showing it to you. What you see
is your browser's interpretation of how the web page should look (note: this is actually an
important point - it's why you should test your site using a variety of browsers).
~1~
Computer Application-II
Notes
Unit - III
Body
The head is used for text and tags that do not
show directly on the
page.
The body is used for text and tags that are shown directly on the page.
Finally, all webpages have an <html> tag at the beginning and the end, telling the browser where
the document starts and where it stops.
The most basic code - the code you will use for any page you make, is shown below:
HEAD SECTION
The head section of the webpage includes all the stuff that does not show directly on the
resulting page.
~2~
Computer Application-II
Notes
Unit - III
The <title> and </title> tags encapsulate the title of your page. The title is what shows in the top
of your browser window when the page is loaded.
Right now it should say something like "Basics - Html Tutorial" on top of the window containing
this text.
Another thing you will often see in the head section is metatags. Metatags are used for, among
other things, to improve the rankings in search engines.
Quite often the head section contains javascript which is a programming language for more
complex HTML pages.
Finally, more and more pages contain codes for cascading style sheets (CSS).
CSS is a rather new technique for optimizing the layout of major websites.
Since these aspects are way out of reach at this stage we will proceed with explaining the body
section
BODY SECTION
The body of the document contains all that can be seen when the user loads the page.
In the rest of this tutorial you can learn in detail about all the different aspects of HTML,
including:
Text
o
o
o
o
Links
o
o
o
Formatting
Resizing
Layout
Listing
To local pages
To pages at other sites
To bookmarks
Images
Inserting images (GIF and jpg)
Adding a link to an image
Backgrounds
o Colors
o Images
o Fixed Image
Tables
Frames
Forms
Metatags
Hexadecimal Colors
o
o
~3~
Computer Application-II
Notes
Unit - III
Document Elements -- These are the tags that set up the sections of a web page, as well as
identifying it as a web page.
Base elements:
<html></html> -- defines the page as an html document
<head></head> -- area at the beginning that provides information to the browser, but does not
show on the page
<title></title> -- element within heading that shows the title of the page. This is the title that
shows on the top of the browser and for bookmark purposes, but does not appear on the page
itself.
<body></body> -- defines the actual body of the page
Here's how the basic format for a web page could look:
<html>
<head>
<title>My Web Page</title>
</head>
<body>
Main body of the page, with text, pictures, etc.
</body>
</html>
~4~
Computer Application-II
Notes
Unit - III
Container Tags -- Container tags are used to affect a certain portion of your material. They
utilize the on/off approach. Container tags operate on the material between the opening tag <
tag> and the closing tag </ tag>
Closed Tags:
Start tag
End Tag
How it looks
<b>
</b>
<strong>
</strong>
<strong>Strong</strong> is
similar to bold but may
depend on the browser
<i>
</i>
<cite>
</cite>
<cite>Cite</cite> is similar to
italic
<em>
</em>
So is <em>Emphasis</em>
but may depend on browser
<center>
</center>
<center>Centers the
text</center>
<p align=right>
</p>
Right aligned
paragraph.
You can use the "p" tag
as a container to align
text to the right
<blockquote>
</blockquote>
Use blockquote to
indent a section of text
from both sides. Great
for quoted sections in a
paper. Also very
effective to use on an
entire page to keep
things from getting too
close to the edge.
<h3>
</h3>
<H3>Use H1 or H2 or H3 etc.
for headings</H3>It
automatically adds a
Use H1 or H2 or H3
etc. for headings
It automatically adds a
~5~
Computer Application-II
Notes
Unit - III
<font size=+2>
</font>
<font size=6>
</font>
<font
color="#0000FF">
</font>
<font
face="Verdana,
Arial, Helvetica,
sans-serif">
</font>
<blink>
</blink>
<ul>
</ul>
Unordered
List.<ul><li>Creates a list
with bullets<li>"li" is used to
denote list items<li>Each
appears with a bullet<p>A
break with no "li" gives an
Unordered List.
Creates a list
with bullets
"li" is used to
denote list items
Each appears
~6~
Computer Application-II
Notes
Unit - III
with a bullet
A break with no
"li" gives an
item without
bullet.
<ol>
</ol>
Ordered List.<ol><li>Creates
a list with numbers<li>"li" is
used to denote list
items<li>Each appears with a
consecutive<p>A break with
no "li" gives an item without a
number.</ol>
Ordered List.
1. Creates a list
with numbers
2. "li" is used to
denote list items
3. Each appears
with a number
A break with no
"li" gives an
item without a
number.
<dl>
</dl>
Definition
List.<dl><li>Creates a list
with bullets, but the list items
are not indented<li>"li" is
used to denote list
items<li>Each appears with a
bullet<p>A break with no "li"
gives an item without
bullet.</dl>
Definition List.
Creates a list with
bullets, but the list items
are not indented
"li" is used to denote
list items
Each appears with a
bullet
A break with no "li"
gives an item without
bullet.
<tt>
</tt>
This changes to
<tt>typewriter style text</tt>
within your text.
This changes to
typewriter style text
within your text.
<pre>
</pre>
Empty tag
~7~
Computer Application-II
Notes
Unit - III
An empty tag is a start tag that does not take an end tag.
In an empty tag, there is no data apart from that contained in the tag itself, either implicitly or by
the use of attributes.
EMPTY elements
In the HTML Document Type Definition, a very few elements are declared as EMPTY. This
means two things:
1. They do not contain any text. They are used simply as markers (and in some cases are
used for whatever is contained in their attributes.
2. EMPTY attributes are not permitted to have an end-tag. Thus <img
src="blahblah.gif"></img> is illegal.
Of the elements used in SUL/AIR, the only EMPTY elements are
hr Horizonal rule
br Line break
img Inline image
input Input
<Hr> and <br> are used simply as markers and cause a horizontal rule or line break to be
inserted in the output. <img> and <input> (which is only used in forms), are used for the
attributes they carry. For example, <img src="globedfruit.gif"> tells the browser to insert the file
"globedfruit.gif" into the output.
There are several other EMPTY elements (<link>, <isindex>, <base>, <meta>, <nextid>), but
these are not normally used in SUL/AIR documents
Do not confuse an EMPTY element with an element that just happens to have nothing in it at the
moment.
Blockquote
The blockquote tag indents the text (both on the left and right) inside the tags. The blockquote
tag looks like this:
<blockquote>...</blockquote>
and displays like this:
Blockquoted text is often used for indenting big blocks of text such as quotations. The text will
be indented until the ending tag is encountered. Again, note that the text here is indented on both
the left and the right margins.
~8~
Computer Application-II
Notes
Unit - III
First, you would define the name "important" in the fourth paragraph with the name tag
<a name="important">First sentence in fourth paragraph</a>
Next, create the link to this "important" anchor (at the start of "chapter2.html"). It would look
like:
<a href="#important">link to important stuff</a>
The pound sign in front of the anchor name tells the browser to look for the link inside the
document already loaded instead of looking elsewhere in another file.
Note that anchor names are case sensitve, and that some kind of non-blank text must
appear in the named anchor tag.
Named anchors within another document
There may be times when you not only want to link to a specific document, but more precisely,
you want to link to a particular section of that other document. As an example, suppose you wish
to set up a link from the document "Our first HTML document" to a particular section in a
second document called "chapter2.html".
First, you set up a named anchor in the document you are linking to (chapter2.html). To do this,
go to the section in your second document where you want the reader to begin and define a
named anchor. Name this anchor "important". Insert the following tag in the appropriate place in
the second document:
<a name="important">some text</a>
Now to create the link in your first document. In your first document you need to include not
only the file name, but the name you defined for the anchor. This named anchor is separated
from the file name by a pound sign (#). Place this tag where you want the link to show up (the
highlighted text).
<a href="http://www.here.edu/chapter2.html#important">important part</a>
A user would see that the first document has the words "important part" highlighted. Clicking on
this highlighted text would take them to the "important" section in the second document.
~9~
Computer Application-II
Notes
Unit - III
You can also link across directories to a document by relative position. For example
<a href="../third_doc.html">Go to third page</a>
links to a document in one directory hierarchy higher than the current document.
Relative links are strongly encouraged as they are easier to type and allow you to move groups
of files from one machine to another without editing the files at all. Naturally though, relative
linking becomes more and more dangerous the more directories you traverse. With that in mind,
it's usually best to use relative linking only within files that are part of a single project (such as
this HTML tutorial).
HTML Formatting
As you may have seen already, there are many ways to format text in HTML. Besides
paragraphs, here are two main commands for managing text in block form.
pre - Used to direct the browser to display a section of text exactly as it is typed with
spaces included.
blockquote - Used to format a block of text as a long quote indented more than the
surrounding text on the left and the right.
The PRE element
PRE element attributes
~ 10 ~
Computer Application-II
Notes
Unit - III
The HR element
HR Element Attributes
http://www.comptechdoc.org/guides/htmlguide/htmlformatline.html (1 of 3)7/21/2003 7:44:55
AM HTML Line Formatting
~ 11 ~
Computer Application-II
Notes
Unit - III
ALIGN="RIGHT" - (Depreciated). Sets the alignment of the line on the page to LEFT,
RIGHT, or CENTER. The default is CENTER. The alignment is without purpose if the line
width is 100%.
WIDTH="50%" - (Depreciated). Sets the width of the line across the page as a % or in
pixels. The default is 100%.
COLOR="green"; - (Depreciated). Sets the color of the line. It may be expressed as one
of the words, red, blue, green, etcetera, but may also be expressed in the #RRGGBB color
format.
~ 12 ~
Computer Application-II
Notes
Unit - III
FACE="roman" - The font name to be used. If there is more than one font name
separated by commas the first font that can be found is used.
<BASEFONT> - Used to set the default font size on the current page. SIZE="2" Specifies default font size with a value between 1 and 7.
IMG:
The <IMG> tag is used to embed graphics in HTML pages. They may be embedded inside other
elements such as anchors. When embedded inside an anchor, then the user left clicks on the
image, they will go to the designated link (rather, their browser will load a file from the
designated link). The <IMG> element has no ending tag.
IMG Attributes
SRC="../greenhomebutton.gif" - The path and filename of the image which specifies its
location.
ALIGN="TOP" - (Depreciated). Sets the image alignment. The image is aligned to the
left or right column if the value is LEFT or RIGHT,The values, TOP, MIDDLE, BOTTOM,
ABSMIDDLE, and ABSBOTTOM, set the vertical alignment with items in the same line.
VSPACE=3 - (Depreciated). The space between the image and the text above and below
it in pixels.
~ 13 ~
Computer Application-II
Notes
Unit - III
HSPACE=5 - (Depreciated). The space between the image and the text to the left and
right of it in pixels.
HEIGHT=33 - The height of the image. If this is not specified, the image will be the size
as determined by the gif file. This can be set in pixels or a percentage of the browser window
height.
WIDTH=115 - The width of the image. If this is not specified, the image will be the size
as determined by the gif file. This can be set in pixels or a percentage of the browser window
width.
ISMAP - Identifies the image as an image map. The image map lets the user point and
click different parts of the image to load other web pages.
~ 14 ~
Computer Application-II
Notes
Unit - III
displayable. This usually occur if it cannot be found or if the user has their browser controls set
not to display pictures.
Example 2
In this example the additional feature is added that sets the size of the picture relative to the size
of the browser window. The size of the picture is set to 20% of the height of the browser window
and 40% of the width.
<img src="MyPicture.gif" alt="Outdoor Scene" height="20%" width="40%">
<a href="Picture1.gif"><img src="SmallPicture.gif" ALT="Picture1" height="20%"
width="40%"></a>
<MAP> - Starts a client-side image map. This must be referenced in an image <IMG>
tag. This element will include <AREA> tags.
~ 15 ~
Computer Application-II
Notes
Unit - III
Example Code
<img src="airplane.gif" ismap usemap="#airplane.map"></a> <map
name="airplane.map"><area shape="rect coordsS="2,50,102,101"
HREF="leftwing.html"><area shape="rect" coords="110,10,160,300" HREF="fusalage.html">
<area shape="rect" coords="162,50,262,101" HREF="rightwing.html"> </map>
http://www.
~ 16 ~
Computer Application-II
Notes
Unit - III
Here's another colored line in HTML code (The second line uses style commands to set attributes
rather than directly using some of the older attributes that are being depreciated):
<hr size="15" align="left" width="100%" color="#FF0000"><hr style="height: '15'; text-align:
'left'; color: '#FF0000'; width: '100%'">
~ 17 ~