ITC lab9
ITC lab9
Objective
Understand Hypertext Mark-up Language
Developing web pages
Understand basic tags
Equipment Required
Personal System
HTML stands for Hypertext Markup Language, and it is the most widely used language to write
Web Pages. As its name suggests, HTML is a markup language.
Hypertext refers to a way in which Web pages (HTML documents) are linked together.
When you click a link in a Web page, you are using hypertext.
Markup Language describes how HTML works. With a markup language, you simply
"mark up" a text document with tags that tell a Web browser how to structure it to
display.
Originally, HTML was developed with the intent of defining the structure of documents like
headings, paragraphs, lists, and so forth to facilitate the sharing of scientific information between
researchers.
All you need to do to use HTML is to learn what type of markup to use to get the results you
want.
You have basic HTML document now, to see some result put the following code in title and body
tags.
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document description goes here.....</p>
Now you have created one HTML page and you can use a Web Browser to open this HTML file
to see the result. Hope you understood that Web Pages are nothing but they are simple HTML
files with some content which can be rendered using Web Browsers.
Here <html>, <head>,...<p>, <h1> etc. are called HTML tags. HTML tags are building blocks of
an HTML document nd we will learn all the HTML tags in subsequent labs.
NOTE: One HTML file can have extension as .htm or .html. So, you can use either of them
based on your comfort.
An HTML document starts and ends with <html> and >/html> tags. These tags tell the browser that
the entire document is composed in HTML. Inside these two tags, the document is split into two
sections:
The <head>...</head> elements, which contain information about the document such as
title of the document, author of the document etc. Information inside this tag does not
display outside.
The <body>...</body> elements, which contain the real content of the document that you
see on your screen.
Every tag consists of a tag name, sometimes followed by an optional list of tag attributes, all
placed between opening and closing brackets (< and >). The simplest tag is nothing more than a
name appropriately enclosed in brackets, such as <head> and <i>. More complicated tags contain
one or more attributes, which specify or modify the behavior of the tag.
According to the HTML standard, tag and attribute names are not case-sensitive. There's no
difference in effect between <head>, <Head>, <HEAD>, or even <HeaD>; they are all equivalent.
But with XHTML, case is important: all current standard tag and attribute names are in lowercase.
HTML is Forgiving?
A very good quality associated with all the browsers is that they would not give any error if you
have not put any HTML tag or attribute properly. They will just ignore that tag or attribute and will
apply only correct tags and attributes before displaying the result.
We can not say, HTML is forgiving because this is just a markup language and required to
format documents.
The basic structure for all HTML documents is simple and should include the following minimum
elements or tags:
Remember that before an opening <html> tag, an XHTML document can contain the optional
XML declaration, and it should always contain a DOCTYPE declaration indicating which version of
XHTML it uses.
Now we will explain each of these tags one by one. In this tutorial you will find the terms
element and tag are used interchangeably.
The <html> element is the containing element for the whole HTML document. Each HTML
document should have one <html> and each document should end with a closing </html> tag.
Following two elements appear as direct children of an <html> element:
<head>
<body>
As such, start and end HTML tags enclose all the other HTML tags you use to describe the Web
page.
The <head> element is just a container for all other header elements. It should be the first thing
to appear after the opening <html> tag.
Each <head> element should contain a <title> element indicating the title of the document,
although it may also contain any combination of the following elements, in any order:
The <base> tag is used to areate a "base" url for all links on the page.
The <object> tag is designed to include images, JavaScript objects, Flash animations,
MP3 files, QuickTime movies and other components of a page.
The <link> tag is used to link to an external file, such as a style sheet or JavaScript file.
The <style> tag is used to include CSS rules inside the document.
The <script> tag is used to include JAVAScript or VBScript inside the document
The <meta> tag includes information about the document such as keywords and a
description, which are particularly helpful for search applications.
Example:
You should specify a title for every page that you write inside the <title> element. This element is a
child of the <head> element). It is used in several ways:
Therefore it is important to use a title that really describes the content of your site. The <title>
element should contain only the text for the title and it may not contain any other elements.
Example:
A <body> element may contain anything from a couple of paragraphs under a heading to more
complicated layouts containing forms and tables.
Most of what you will be learning in this and the following five chapters will be written between
the opening <body> tag and closing </body> tag.
Example:
<body>
<p>This is a paragraph tag.</p>
</body>
Now if we will put all these tags together, it will constitute a complete HTML document as
follows:
<html>
<head>
<title>HTML Basic tags</title>
<meta name="Keywords" content="HTML, Web Pages" />
<meta name="description" content="HTML Basic Tags" />
<base href="http://www.tutorialspoint.com" />
<link rel="stylesheet" type="text/css" href="tp.css" />
<script type="text/javascript">
_uacct = "UA-232293";
urchinTracker();
</script>
</head>
HTML lets you specify metadata - information about a document rather than document content - in
a variety of ways. The META element can be used to include name/value pairs describing
properties of the HTML document, such as author, Expiry Date, a list of key words, author etc.
The <meta> tag is an empty element and so does not have a closing tag, rather, <meta> tags carry
information within attributes, so you need a forward slash character at the end of the element.
Metadata provided by using meta tag is a very important part of the web. It can assist search
engines in finding the best match when a user performs a search. Search engines will often look at
any metadata attached to a page - especially keywords - and rank it higher than another page
with less relevant metadata, or with no metadata at all.
You can add metadata to your web pages by placing <meta> tags between the <head> and
</head> tags. The can include the following attributes:
Attribute Description
Name Name for the property. Can be anything. Examples include, keywords,
description, author, revised, generator etc.
scheme Specifies a scheme to use to interpret the property's value (as declared in the
content attribute).
http- Used for http response message headers. For example http-equiv can be used to
equi refresh the page or to set a cookie. Values include content-type, expires,
v refresh and set-cookie.
NOTE: Core attributes for all the elements are discussed in next chapter.
HTML Attributes
Attributes are another important part of HTML markup. An attribute is used to define the
characteristics of an element and is placed inside the element's opening tag. All attributes are
made up of two parts: a name and a value:
The name is the property you want to set. For example, the <font> element in the
example carries an attribute whose name is face, which you can use to indicate which
typeface you want the text to appear in.
The value is what you want the value of the property to be. The first example was
supposed to use the Arial typeface, so the value of the face attribute is Arial.
The value of the attribute should be put in double quotation marks, and is separated from the
name by the equals sign. You can see that a color for the text has been specified as well as the
typeface in this <font> element:
Many HTML tags have a unique set of their own attributes. These will be discussed as each tag is
introduced throughout the tutorial. Right now we want to focus on a set of generic attributes that
can be used with just about every HTML Tag in existence.
Core Attributes:
The four core attributes that can be used on the majority of HTML elements (although not all)
are:
id
title
class
style
The id Attribute:
The id attribute can be used to uniquely identify any element within a page ( or style sheet ).
There are two primary reasons that you might want to use an id attribute on an element:
We will discuss style sheet in separate tutorial. For now, the id attribute could be used to
distinguish between two paragraph elements, like so:
<p id="html">This para explains what is HTML</p>
<p id="css">This para explains what is Casecading Style Sheet</p>
Note that there are some special rules for the value of the id attribute, it must:
Begin with a letter (A.Z or a.z) and can then be followed by any number of letters,
digits (0.9), hyphens, underscores, colons, and periods.
Remain unique within that document; no two attributes may have the same value
within that HTML document.
The behavior of this attribute will depend upon the element that carries it, although it is often
displayed as a tooltip or while the element is loading.
For example:
Now try to bring your cursor over "Titled Heading Tag Example" and see the result.
The class attribute is used to associate an element with a style sheet, and specifies the class of
element. You learn more about the use of the class attribute when you will learn Casecading
Style Sheet (CSS). So for now you can avoid it.
The value of the attribute may also be a space-separated list of class names. For example:
The style attribute allows you to specify CSS rules within the element. For example:
If you want people to read what you have written, then structuring your text well is even more
important on the Web than when writing for print. People have trouble reading wide, long,
paragraphs of text on Web sites unless they are broken up well.
This section will teach you basic text formatting elements like heading elements and paragraph
elements.
Before you start to mark up your text, it is best to understand what HTML does when it comes
across spaces and how browsers treat long sentences and paragraphs of text.
You might think that if you put several consecutive spaces between two words, the spaces
would appear between those words onscreen, but this is not the case; by default, only one space
will be displayed. This is known as white space collapsing. So, you need to use special HTML
tags to create multiple spaces.
Similarly, if you start a new line in your source document, or you have consecutive empty lines,
these will be ignored and simply treated as one space. So, you need to use special HTML tags to
create a greater number of empty lines.
Any documents starts with a heading. You use different sizes for your headings. HTML also have
six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While
displaying any heading, browser adds one line before and after that heading.
Example:
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
The <p> element offers a way to structure your text. Each paragraph of text should go in
between an opening <p> and closing </p> tag as shown below in the example:
This is jutified. This works when you have multiple lines in your paragraph and you want to
justfy all the lines so that they can look more nice.
Whenever you use the <br /> element, anything following it starts on the next line. This tag is an
example of an empty element, where you do not need opening and closing tags, as there is nothing
to go in between them.
Note: The <br /> element has a space between the characters br and the forward slash. If you omit
this space, older browsers will have trouble rendering the line break, while if you miss the forward
slash character and just use <br> it is not valid XHTML
Example:
Hello<br />
You come most carefully upon your hour.<br />
Thanks<br />
Mahnaz
Hello
Thanks
You can use <center> tag to put any content in the center of the page or any table cell. Example:
Nonbreaking Spaces:
Suppose you were to use the phrase "12 Angry Men." Here you would not want a browser to
split the "12" and "Angry" across two lines:
A good example of this technique appears in the movie "12 Angry Men."
In cases where you do not want the client browser to break text, you should use a nonbreaking
space entity ( ) instead of a normal space. For example, when coding the "12 Angry Men"
paragraph, you would use something similar to the following code:
Soft Hyphens:
Occasionally, you will want to allow a browser to hyphenate long words to better justify a
paragraph. For example, consider the following code and its resulting output.
<p style="text-align: justify;"> The morbid fear of the number 13, or triskaidekaphobia, has
plagued some important historic figures like Mahamiya and Nanao.</p>
In cases where you want a client browser to be able to hyphenate a word if necessary, use the soft
hyphen entity (­) to specify where a word should be hyphenated. So above example should
be written as follows:
<p style="text-align: justify;"> Example for soft hyphen - The morbid fear of the number 13, or
tri­skai­deka­phobia, has plagued some important historic figures like Mahamiya
and Nanao.</p>
Example for soft hyphen - The morbid fear of the number 13, or triskaidekaphobia, has plagued
some important historic figures like Mahamiya and Nanao.
Sometimes you want your text to follow the exact format of how it is written in the HTML
document. In those cases, you can use the preformatted tag (<pre>).
Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document.
<pre>
function testFunction( strText ){
alert (strText)
}
Horizontal rules are used to visually break up sections of a document. The <hr> tag creates a line
from the current position in the document to the right margin and breaks the line accordingly.
For example you may want to give a line between two paragraphs as follows:
Again <hr /> tag is an example of an empty element, where you do not need opening and
closing tags, as there is nothing to go in between them.
Note: The <hr /> element has a space between the characters br and the forward slash. If you omit
this space, older browsers will have trouble rendering the line break, while if you miss the forward
slash character and just use <hr> it is not valid XHTML.
Presentational Tags:
If you use a word processor, you are familiar with the ability to make text bold, italicized, or
underlined; these are just three of the ten options available to indicate how text can appear in
HTML and XHTML.
Anything that appears in a <b>...</b> element is displayed in bold, like the word bold here:
Anything that appears in a <i>...</i> element is displayed in italicized, like the word italicized
here:
Anything that appears in a <u>...</u> element is displayed with underline, like the word
underlined here:
The content of a <tt> element is written in monospaced font. Most fonts are known as variable-
width fonts because different letters are of different widths (for example, the letter m is wider than
the letter i). In a monospaced font, however, each letter is the same width.
The content of a <sup> element is written in superscript; the font size used is the same size as the
characters surrounding it but is displayed half a character.s height above the other characters.
superscript
The following word uses a typeface.
Subscript Text - The <sub> Element:
The content of a <sub> element is written in subscript; the font size used is the same as the
characters surrounding it, but is displayed half a character.s height beneath the other characters.
The content of the <big> element is displayed one font size larger than the rest of the text
surrounding it.
The content of the <small> element is displayed one font size smaller than the rest of the text
surrounding it.
<p>The following word uses a <small>small</small> typeface.</p>
The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element to
indicate that all of the elements within that <div> element relate to the footnotes. You might then
attach a style to this <div> element so that they appear using a special set of style rules.
Content Articles
The <span> element, on the other hand, can be used to group inline elements only. So, if you had a
part of a sentence or paragraph you wanted to group together you could use the <span> element.
This is the example of span tag and the div tag alongwith CSS
These tags are commonly used with CSS to allow you to attach a style to a section of a page.
While some of these phrase elements are displayed in a similar manner to the <b>, <i>,
<pre>, and <tt> elements you have already seen, they are designed for specific purposes. For
example, the <em> and <strong> elements give text emphasis and strong emphasis respectively
and there are several elements for marking up quotes.
The content of an <em> element is intended to be a point of emphasis in your document, and it is
usually displayed in italicized text. The kind of emphasis intended is on words such as "must" in the
following sentence:
The <strong> element is intended to show strong emphasis for its content; stronger emphasis than
the <em> element. As with the <em> element, the <strong> element should be used only when
you want to add strong emphasis to part of a document.
HTML Comments
Comments are piece of code which is ignored by any web browser. It is good practice to
comment your code, especially in complex documents, to indicate sections of a document, and any
other notes to anyone looking at the code. Comments help you and others understand your code.
HTML Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at
the beginning and end of EVERY line to be treated as a comment.
Comments do not nest, and the double-dash sequence "--" may not appear inside a comment
except as part of the closing --> tag. You must also make sure that there are no spaces in the start-
of-comment string.
For example: Given line is a valid comment in HTML
But following line is not a valid comment and will be displayed by the borwser. This is because
there is a space between the left angle bracket and the exclamation mark.
Be careful if you use comments to "comment out" HTML that would otherwise be shown to the
user, since some older browsers will still pay attention to angle brackets inside the comment and
close the comment prematurely -- so that some of the text that was supposed to be inside the
comment mistakenly appears as part of the document.
Multiline Comments:
You have seen how to comment a single line in HTML. You can comment multiple lines by the
special beginning tag <!-- and ending tag --> placed before the first line and end of the lastline to be
treated as a comment.
For example:
<!--
This is a multiline comment <br />
and can span through as many as lines you like.
<script>
<!--
document.write("Hello World!")
//-->
HTML Fonts
Font face and color depends entirely on the computer and browser that is being used to view
your page. But the <font> tag is used to add style, size, and color to the text on your site. You can
use a <basefont> tag to set all of your text to the same size, face, and color.
The font tag is having three attributes called size, color, and face to customize your fonts.
To change any of the font attributes at any time within your page, simply use the <font> tag. The
text that follows will remain changed until you close with the </font> tag. You can change any or
all of the font attributes at the one time, by including all the required changes within the one <font>
tag.
NOTE: The font and basefont tags are deprecated and it is supposed to be removed in a future
version of HTML. So it should not be used. Its is suggested to use css styles to manipulate your font.
Font Size:
You can set the size of your font with size attribute. The range of accepted values is from
1(smallest) to 7(largest). The default size of a font is 3.
Example:
Font size="1"
Font size="2"
Font size="3"
Font size="4"
Font size="5"
Font size="6"
Font size="7"
SPECIFY THE RELATIVE FONT SIZE. <font size="+n"> or <font size="-
n">: You can specify how many sizes larger or how many sizes smaller than the preset
font size should be.
Example:
Font size="-1"
Font size="+1"
Font size="+2"
Font size="+3"
Font size="+4"
Font Face:
You can set any font you like using face attribute but be aware that if the user viewing the page
doesn't have the font installed, they will not be able to see it. Instead they will default to Times
New Roman of your font with size attribute. See below few examples on using different font face
Example:
A visitor will only be able to see your font if they have that font installed on their computer. So, it
is possible to specify two or more font face alternatives by listing the font face names,
separated by a comma.
Example:
<font face="arial,helvetica">
<font face="Lucida Calligraphy,Comic Sans MS,Lucida Console>
When your page is loaded, their browser will display the first font face that it has available. If
none of your selections are installed then it will display the default font face Times New
Roman.
Font Color:
You can set any font color you like using color attribute. You can specify the color that you want by
either the color name or hexadecimal code for that color. Check a complete list of HTML
Example:
HTML Images
Images are very important to beautify as well as to depicts many concepts on your web page. Its is
true that one single image is worth than thousands of words. So as a Web Developer you should
have clear understanding on how to use images in your web pages.
You will insert any image in your web page by using <img> tag. Following is the simple syntax to
use this tag.
width: sets width of the image. This will have a value like 10 or 20%etc.
height: sets height of the image. This will have a value like 10 or 20% etc.
border: sets a border around the image. This will have a value like 1 or 2 etc.
src: specifies URL of the image file.
alt: this is an alternate text which will be displayed if image is missing.
align: this sets horizontal alignment of the image and takes value either left, right or
center.
valign: this sets vertical alignment of the image and takes value either top, bottom or
center.
hspace: horizontal space around the image. This will have a value like 10 or 20%etc.
vspace: vertical space around the image. This will have a value like 10 or 20%etc.
name: name of the image with in the document.
id: id of the image with in the document.
style: this will be used if you are using CSS.
title: specifies a text title. The browser, perhaps flashing the title when the mouse
passes over the link.
ismap and usemap: These attributes for the <img> tag tell the browser that the image
is a special mouse-selectable visual map of one or more hyperlinks, commonly known as
an image map. We will see how to use these attributes in Image Links chapter.
A Simple Example:
<img src="http://www.tutorialspoint.com/images/html.gif"
alt="HTML Tutorial" width="100" height="100"
Remember that all the images will have a border by default. In our examples its not showing
because our global style sheet has set img {border:0px;} which means that no border will be
displayed till it is mentioned explicitly.
You can remove an image border by setting border="0" or through CSS by setting img
{border:0px;}.
Example 1:
<p>This is the first paragraph that appears above the paragraph with the image!</p>
The image will appear along the right hand side of the paragraph. As you can see this is very
nice for adding a little eye candy that relates to the specified paragraph.</p>
<p>The left and right image-alignment values tell the browser to place an image against the left
or right margin, respectively, of the current text flow. The browser then renders subsequent
document content in the remaining portion of the flow adjacent to the image. The net result is
This is the first paragraph that appears above the paragraph with the image!
The image will appear along the right hand side of the paragraph. As you can see
this is very nice for adding a little eye candy that relates to the specified
paragraph.
The left and right image-alignment values tell the browser to place an image
against the left or right margin, respectively, of the current text flow. The browser
then renders subsequent document content in the remaining portion of the flow adjacent to the
Example 2:
You can use vspace or hspace attributes if you want to keep some distance between text and
image. Let us revise above example:
<p>This is the first paragraph that appears above the paragraph with the image!</p>
The image will appear along the right hand side of the paragraph. As you can see this is very
nice for adding a little eye candy that relates to the specified paragraph.</p>
<p>The left and right image-alignment values tell the browser to place an image against the left
or right margin, respectively, of the current text flow. The browser then renders subsequent
document content in the remaining portion of the flow adjacent to the image. The net result is
This will produce following result:
This is the first paragraph that appears above the paragraph with the image!
The image will appear along the right hand side of the paragraph. As you can
see this is very nice for adding a little eye candy that relates to the specified
paragraph.
The left and right image-alignment values tell the browser to place an image
against the left or right margin, respectively, of the current text flow. The
browser then renders subsequent document content in the remaining portion of the flow
Web pages can contain links that take you directly to other pages and even specific parts of a
given page. These links are known as hyperlinks.
Hyperlinks allow visitors to navigate between Web sites by clicking on words, phrases, and
images. Thus you can create hyperlinks using text or images available on your any web page.
In this tutorial you will learn how to create text links between the different pages of your site,
links within pages of your sites, and how to link to other sites ( or external sites). If you want to
know more about URL then
A link is specified using the <a> element. This element is called anchor tag as well. Anything
between the opening <a> tag and the closing </a> tag becomes part of the link and a user can click
that part to reach to the linked document.
href: specifies the URL of the target of a hyperlink. Its value is any valid document
URL, absolute or relative, including a fragment identifier or a JavaScript code fragment.
target: specify where to display the contents of a selected hyperlink. If set to "_blank" then
a new window will be opened to display the loaded page, if set to "_top" or "_parent"
then same window will be used to display the loaded document, if set to "_self" then
loads the new page in current window. By default its "_self".
name & id: attributes places a label within a document. When that label is used in a link
to that document, it is the equivalent of telling the browser to goto that label.
event: attributes like onClick, onMouseOver etc. are used to trigger any Javascript
ot VBscript code.
title: attribute lets you specify a title for the document to which you are linking. The
value of the attribute is any string, enclosed in quotation marks. The browser might use it
when displaying the link, perhaps flashing the title when the mouse passes over the link.
accesskey: attribute attribute provides a keyboard shortcut that can be used to activate a
link. For example, you could make the T key an access key so that when the user presses
either the Alt or Ctrl key on his keyboard (depending on his operating system) along
with the T key, the link gets activated.
A Simple Example:
This will produce following result, Click and come back to proceed with rest of the tutorial:
You can create a link to a particular section of a page by using name attribute. Here we will
create three links with-in this page itself.
First create a link to reach to the top of this page. Here is the code we have used for the title
heading HTML Text Links
<h1>HTML Text Links <a name="top"></a></h1>
Now you have a place where you can reach. To reach to this place use the following code with- in
this document anywhere:
This will produce following link and you try using this link to reach to the top of this page:
Go to the Top
NOTE: Here we are using relative path. You can give complete URL and then # and then link
name eg. http://www.tutorialspoint.com/html/html_text_links.htm#top
You can use this type of URL in any other page to reach directly to a particular section.
You can set colors of your links, active links and visited links using link, alink and vlink
attributes of <body> tag. But it is recommended to use CSS to set colors of links, visited links and
active links.
Following is the example we have used for our web side tutorialspoint.com
You can refer to Style Sheet Tutorial for a complete understanding on CSS. Otherwise
you can use <body> tag to set link colors. Here is the syntax.
<body alink="#FF0000" link="#900B09" vlink="#900B09">
.......
</body>
Previous chapters has tought you how to create hyper text link using text and how to use
images in your web page. Now we will learn how to use images to create hyper links. See
example below:
This was the simpletest way of creating hyperlinks using images. Next we will see how we can
create Mouse-Sensitive Image Links.
Lab Task:
Create your CV in HTML by using all above mentioned concepts of HTML. Write
complete procedure of completing the task.