Unit 5
Unit 5
HyperText Markup Language (HTML) is the main markup language for displaying web pages and other information that can
be displayed in a web browser.
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 most commonly come in pairs like <h1> and </h1>, although some tags, known as empty elements,
are unpaired, for example <img>. 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). In between these tags web designers can add text, tags, comments and other types of text-
based content.
HTML Tags
HTML Elements
HTML documents are composed entirely of HTML elements that, in their most general form have three components: a pair
of tags, a "start tag" and "end tag"; some attributes within the start tag; and finally, any textual and graphical content between
2 Unit- 5 HTML _ MHM
the start and end tags, perhaps including other nested elements. The HTML element is everything between and including the
start and end tags. Each tag is enclosed in angle brackets.
The general form of an HTML element is therefore: <tag attribute1="value1" attribute2="value2">content</tag> . Some HTML
elements are defined as empty elements and take the form <tag attribute1="value1" attribute2="value2" >. Empty elements may
enclose no content, for instance, the BR tag or the inline IMG tag. The name of an HTML element is the name used in the tags.
Note that the end tag's name is preceded by a slash character, "/", and that in empty elements the end tag is neither required nor
allowed. If attributes are not mentioned, default values are used in each case.
Element examples
Header of the HTML document:<head>...</head>. Usually the title should be included in the head, for example:
<head>
<title>The Title</title>
</head>
<h1>Heading1</h1>
<h2>Heading2</h2>
<h3>Heading3</h3>
<h4>Heading4</h4>
<h5>Heading5</h5>
<h6>Heading6</h6>
HTML Attributes
Attribute Example
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
Example
HTML uses tags like <b> and <i> for formatting output, like bold or italic text.
These HTML tags are called formatting tags (look at the bottom of this page for a complete reference).
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.
Paragraphs
Paragraphs are defined with the <p> tag. Think of a paragraph as a block of text. You can use the align attribute with a
paragraph tag as well.
<p align="left">This is a paragraph</p>
<p align="center">this is another paragraph</p>
Line Breaks
The <br> tag is used when you want to start a new line, but don't want to start a new paragraph. The <br> tag forces a line break wherever you place
it. It is similar to single spacing in a document
Horizontal Rule
The <hr> element is used for horizontal LINE that act as dividers between sections,
HTML Links
HTML uses the <a> anchor tag to create a link to another document or web page.
The Anchor Tag and the Href Attribute
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, Would Display
the href attribute is used to tell the address of the
document or page we are linking to, and the words
between the open and close of the anchor tag will be
displayed as a hyperlink. This Code
4 Unit- 5 HTML _ MHM
HTML Images
The Image Tag and the Src Attribute
The <img> tag is empty, which means that it Would Display
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: This Code
<img src="graphics/chef.gif">
Tables
Tables are defined with the <table> tag. A table is Would Display
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.
This Code
<table> <tr> <td>row 1, cell 1</td> <td>row row 1, cell 1
1, cell 2</td> </tr> <tr> <td>row 2, cell row 1, cell 2
1</td> <td>row 2, cell 2</td> </tr> </table> row 2, cell 1
row 2, cell 2
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
Tables Backgrounds
You can set table background using of the following two ways:
Using bgcolor attribute - You can set background color for whole table
or just for one cell.
Using background attribute - You can set background image for whole
table or just for one cell.
HTML Fonts
Font tag is used to set the font of any text. 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.
HTML Lists
The most common HTML lists are ordered and unordered lists:
HTML Lists
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items are marked with bullets (typically small black circles).
7 Unit- 5 HTML _ MHM
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item in the list):
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
8 Unit- 5 HTML _ MHM
Frames Frames divide a browser window into several pieces or panes, each pane containing a separate XHTML/HTML document. One of
the key advantages that frames offer is that you can then load and reload single panes without having to reload the entire contents of the
browser window. A collection of frames in the browser window is known as a frameset.
The window is divided up into frames in a similar pattern to the way tables are organized: into rows and columns. The simplest of framesets
might just divide the screen into two rows, while a complex frameset could use several rows and columns.
<frameset cols="25%,*,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
ADDING ANIMATION
Attributes:
align - Determines how to align the object. It takes either center, left or right.
autostart - Indicates if the media should start automatically. Netscape default is true, Internet Explorer is false.
loop - Specifies if the sound should be played continuously (set loop to true), a certain number of times (a positive value) or not at
all (false). This is supported by Netscape only.
playcount - Specifies the number of times to play the sound. This is alternat option forloop if you are usiong IE.
hidden - Defines if the object shows on the page. A false value means no and true means yes.
src - URL of the object to be embedded. This can be any recognizable by the user's browser. It could be .mid, .wav, .mp3, .avi and
so on).
volume - Controls volume of the sound. Can be from 0 (off) to 100 (full volume). This attribute is supported by Netscape only.
Flash movies (.swf), AVI's (.avi), and MOV's (.mov) file types are supported by the embed tag.
9 Unit- 5 HTML _ MHM
.swf files - are the file types created by Macromedia's Flash program.
.wmv files - are Microsoft's Window's Media Video file types.
.mov files - are Apple's Quick Time Movie format.
.mpeg files - are movie files created by the Moving Pictures Expert Group.