What Is An HTML File?
What Is An HTML File?
What Is An HTML File?
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is my first homepage. <b>This text is bold</b>
</body>
</html>
Web browser
A web browser is a software application which enables a user to display and interact
with text, images, videos, music 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 website. Web browsers allow a
user to quickly and easily access information provided on many Web pages at many websites by
traversing these links. Web browsers format HTML information for display, so the appearance of
a Web page may differ between browsers.
Some of the Web browsers currently available for personal computers include Mozilla
Firefox, Safari, Konqueror, Opera, Flock, Internet Explorer, Epiphany and AOL Explorer. Web
browsers communicate with Web servers primarily using HTTP (hypertext transfer protocol)
to fetch webpages. HTTP allows Web browsers to submit information to Web servers as well as
fetch Web pages from them.
Pages are located by means of a URL (uniform resource locator), which is treated as an
address, beginning with http: for HTTP access. Many browsers also support a variety of other
URL types and their corresponding protocols, such as gopher: for Gopher (a hierarchical
hyperlinking protocol), ftp: for FTP (file transfer protocol), rtsp: for RTSP (real-time
streaming protocol), and https: for HTTPS (an SSL encrypted version of HTTP).
HTML Elements
HTML documents are text files made up of HTML elements. An element in HTML
represents some kind of structure and generally consists of a start tag, content, and an end tag.
The following is a paragraph element:
<p>
This is the content of the paragraph element.
</p>
In this example the HTML element starts with a start tag: <p>
The content of the HTML element is: This is the content of the paragraph element.
The HTML element ends with an end tag: </p>
HTML Tags
Tags are elements of the HTML document used to specify how the document should be
displayed by the browser. In HTML, each tag has its own specific meaning, which is (in general)
common across all different browsers. Tags are used to mark up the start and end of an HTML
element.
A start tag consists of an opening angle bracket (<) followed by the element name, zero
or more space separated attribute/value pairs, and a closing angle bracket (>).
A start tag with no attributes:
<p>
A start tag with an attribute:
<p class="info">
End tags consist of an opening angle bracket followed by a forward slash, the element
name, and a closing angle bracket:
</p>
There are also some elements that are empty, meaning that they only consist of a single
tag and do not have any content. In HTML, such tags look just like opening tags:
<br>
HTML tags are used to mark-up HTML elements
HTML tags are surrounded by the two characters < and >
The surrounding characters are called angle brackets
HTML tags normally come in pairs like <b> and </b>
The first tag in a pair is the start tag, the second tag is the end tag
The text between the start and end tags is the element content
HTML tags are not case sensitive, <b> means the same as <B>
e.g. <img src="foobar.gif" alt="A foo can be balanced on a bar by placing its fubar on the bar's
foobar.">
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 break 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 end tag like </br>, since a closing tag doesn't
make any sense.
Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment will
be ignored by the browser. You can use comments to explain your code, which can help you
when you edit the source code at a later date.
Exercise 1:
Design a simple page ‘hello.html’ with the title “First Page” and displays following messages as
headings:
Hello World.
This is first HTML page.
With paragraph that describe some information about HTML tags and write proper comments,
heading in it.
Types of List
Unordered Lists
An unordered list is a list of items. The list items are marked with bullets (typically small
black circles) using the attribute ‘TYPE’.
TYPE = DISC | CIRCLE | SQUARE
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers using the
attribute ‘TYPE’.
TYPE = 1 | A | a | I | i type of numerals
START: where to start counting
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.
Definition Lists
A definition list is not a list of items. This is a list of terms and explanation of the terms.
The important attribute of definition list is ‘COMPACT’
COMPACT: take up less space
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.
Nested Lists
A nested list is nothing but not a list of items. This is a list of terms and explanation of
the terms. The important attribute of definition list is ‘COMPACT’
COMPACT: take up less space
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>
Examples:
<address> </address>
The <ADDRESS> tag is used for information such as addresses, authorship and so forth. The
text is usually italicized and in some browsers it is indented.
<address>
Author: of this document:<br />
<a href="mailto:[email protected]">Donald Duck</a>
</address>
HTML automatically adds an extra blank line before and after a heading.
<pre> </pre>
The pre element defines preformatted text. The text enclosed in the pre element usually
preserves spaces and line breaks. The text renders in a fixed-pitch font. The width attribute
defines the maximum number of characters per line (usually 40, 80, or 132)
<p>The pre tag is good for displaying computer code:</p>
<pre>
for i = 1 to 10
print i
next i
</pre>
<font> </font>
The <font> tag specifies the font face, font size, and font color of text.
<font size="3" color="red">
This is some text!
</font>
<font size="1" color="blue" face="arial">
This is some text!
</font>
<font color="red">
You may have read that the <font> tag has been deprecated. This means that the tag is no
longer a part of the HTML specification. While browsers will still support it as it is used for long
time. Alternative way is to use CSS. CSS can do all the same things that the <font> tag can do,
plus a lot more.
<span style="font-family : garamond, times;">this font is
not sans-serif</span>
<span style="color : #9933ff;">this font is purple</span>
<span style="font-size : x-large;">this text is extra
large</span>
One thing CSS can do that the font tag cannot, is CSS can change the background color
behind the text. <span style="background-color : #9933ff;">The background behind
this text is purple</span>
Finally, there are some other tricks you can do with CSS that the font tag cannot do:
src="../../images/logos/GHLogo.gif"
width="34" height="61">
noscrip Alternate content container for non
t script-based rendering. Creates inline <script language="JavaScript">
content for browsers that don't accept
script. <!--
document.write ("ON.")
// -->
</script>
/ --></script>
span Generic language/style container. Marks
a section of a document. <span> is text <div class="Great Books">
level tag and flows inline with text,
whereas <div> is a block level tag and <span class="Title">The Hobbit</span>
inserts breaks before and after itself. by
<span class="Author">J.R.R.
Tolkien</span>.
The NAME attribute specifies the current anchor as a potential bookmark target of other
links. The NAME attribute must be unique on the document. The ID attribute may be used
instead.
The HREF attribute specifies the target of the current anchor. The target is usually an
absolute URL (eg http:\\yadayada) or a relative URL (dogs/nice.htm). The URL may also point
to a specific bookmark on the page with the syntax of URL#bookmark. The bookmark is usually
an <a> tag with its NAME attribute specified. The TARGET attribute names the frame where a
document will be opened.
AttributeValue Description
href URL The target URL of the link
name section_name Names an anchor. Use this attribute to create a bookmark in a
document.
In future versions of XHTML the name attribute will be replaced by
the id attribute!!
target _blank Where to open the target URL.
_parent _self
_top _blank - the target URL will open in a new window
_self - the target URL will open in the same frame as it was
clicked
_parent - the target URL will open in the parent frameset
_top - the target URL will open in the full body of the window
Example
Visit the <a href="index.htm">home page of this directory</a>.
Visit the home page of this directory.
Clicking HERE takes you to THERE, but THERE could really be any place on any page.
Send e-mail to
<a href="mailto:[email protected]?
[email protected]&[email protected]&subject=test&body=world">
[email protected]
</a>
with cc as [email protected]</a>,
bcc as [email protected],
subject as hello, and
body as world.
Send e-mail to [email protected] with cc as [email protected], bcc as [email protected], subject as hello, and body as
world.
JPEG
The Joint Photographic Experts Group (JPEG) is a standards body that developed what is now
known as the JPEG image-encoding format.
Like GIFs, JPEG images are platform-independent and specially compressed for high-
speed transfer via digital communication technologies.
Unlike GIF, JPEG supports tens of thousands of colors for more detailed, photorealistic
digital images.
And JPEG uses special algorithms that yield much higher data-compression ratios. It is
not uncommon, for example, for a 200-KB GIF image to be reduced to a 30-KB JPEG image. To
achieve that amazing compression, JPEG does lose some image data.
Although JPEG is an excellent choice for photographs, it's not a particularly good choice
for illustrations.
The algorithms used for compressing and uncompressing the image leave noticeable
artifacts when dealing with large areas of one color. Therefore, if you're trying to display a
drawing, the GIF format may be preferable.
The JPEG format, usually designated by the .jpg (or .JPG) filename suffix, is nearly
universally understood by today's graphical browsers.
JPEG or GIF?
You may choose to use only JPEG or GIF images in your HTML documents if your
sources for images or your software toolset prefers one over the other format. Both are nearly
universally supported by today's browsers, so there shouldn't be any user-viewing problems.
Nevertheless, we recommend that you acquire the facilities to create and convert to both
formats to take advantage of their unique capabilities. For instance, use GIF's transparency
feature for icons and dingbats. Alternatively, use JPEG for large and colorful images for faster
downloading.
Images are measured in pixels (picture elements), which represent dots of color on the
screen. Users can create images using specialized software, such as Adobe Photoshop Elements,
Macromedia Fireworks and Paint Shop Pro etc.
Examples:
1> <p>An image: <img src="constr4.gif" width="144" height="50">
</p>
<p>A moving image:<img src="hackanm.gif" width="48"
height="48"></p>
<p>Note that the syntax of inserting a moving image is no
different from that of a non-moving image.</p>
4> How to align an image within the text. (if text is large paragraph then image will float
accordingly.)
<p> An image
<img src="hackanm.gif" align="bottom" width="48"
height="48"> in the text</p>
<p>An image
<img src ="hackanm.gif" align="middle" width="48"
height="48"> in the text</p>
<p>An image
<img src ="hackanm.gif" align="top" width="48"
height="48"> in the text </p>
<p>Note that bottom alignment is the default alignment</p>
<p> An image
<img src ="hackanm.gif" width="48" height="48"> in the
text </p>
<p> <img src ="hackanm.gif" width="48" height="48"> An image
before the text </p>
<p> An image after the text <img src ="hackanm.gif"
width="48" height="48"> </p>
5> This example demonstrates how to display an alternate text for an image & image as a
hyperlink.
<img src="goleft.gif" alt="Go Left" width="32" height="32">
<p> Text-only browsers cannot display images and will only
display the text that is specified in the "alt" attribute
for the image. Here, the "alt"-text is "Go Left".</p>
<p> Note that if you hold the mouse pointer over the image,
most browsers will display the "alt"-text. </p>
</body> </html>
<TABLE>
<CAPTION>Caption text for table</CAPTION>
<TR><TH>column1</TH><TH>column2</TH><TH>column3</TH>
<TR><TD>row1data1</TD><TD>row1data2</TD><TD>row1data3</TD>
<TR><TD>row2data1</TD><TD>row2data2</TD><TD>row2data3</TD>
... </TABLE>
<TD> and </TD> set a single table cell. The attributes ROWSPAN & COLSPAN varies
the span of rows and columns in a table and can be helpful for grouping information, adding
emphasis, or eliminating empty cells.
Some of the most important attributes of the <TD> and <TR> tags are:
ALIGN: horizontal alignment of cell contents
VALIGN: vertical alignment of cell contents
WIDTH: width of cell
HEIGHT: height of cell
COLSPAN: number of columns to cover
ROWSPAN: number of rows to cover
NOWRAP: don't word wrap
BGCOLOR: color of the background
BORDERCOLOR: color of border around the table
BORDERCOLORDARK: color of "dark" part of border around the table
BORDERCOLORLIGHT: color of "light" part of border around the table
BACKGROUND: picture to use as background
Example:
1> This example demonstrates how to create tables in an HTML document.
<html><body>
<h4>One row and three columns:</h4>
<table border="1">
<tr> <td>100</td>
<td>200</td>
<td>300</td>
</tr>
</table>
<h4>With a normal border:</h4>
<table border="1">
<tr> <td>First</td>
<td>Row</td>
</tr>
<tr> <td>Second</td>
<td>Row</td>
</tr>
</table>
2> This example demonstrates how to display table caption & headers. (& 2 rel)
<html><body>
<h4>Vertical headers:</h4>\
<table border="1">
<tr> <th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr> <th>Telephone:</th>
<td>555 77 854</td>
</tr>
<tr> <th>Telephone:</th>
<td>555 77 855</td>
</tr>
</table>
</body></html>
3> This example demonstrates how to define table cells that span more than one row or one
column.
<html><body>
<h4>Cell that spans two columns:</h4>
<table border="1">
<tr> <th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr> <td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
<h4>Cell that spans two rows:</h4>
<table border="1">
<tr> <th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr> <th rowspan="2">Telephone:</th>
<td>555 77 854</td>
</tr>
<tr> <td>555 77 855</td>
</tr>
</table>
</body></html>
<h4>With cellspacing:</h4>
<table border="1" cellspacing="10">
<tr> <td>First</td>
<td>Row</td>
</tr>
<tr> <td>Second</td>
<td>Row</td>
</tr>
</table>
<h4>With cellpadding:</h4>
<table border="1" cellpadding="10">
<tr> <td>First</td>
<td>Row</td>
</tr>
<tr> <td>Second</td>
<td>Row</td>
</tr>
</table>
</body></html>
Frames
The use of frames splits the browser window into a group of distinct sub-windows or
panes. By dividing the page into different parts-each of which can be updated separately-there
becomes a number of different interface elements you can offer. Even a simple use of the frame
specification lets you add interface graphics or a corporate logo to a site, while the rest of your
page scrolls beneath it.
Using frames in this way takes you one step closer to the ideal Web interface, because it
makes it as intuitive and universal as possible. Frames are ideal for the following:
Table of Contents (TOC). By placing the TOC in a "column" on your Web page, people
can click around your site or your documentation pages without being forced to
constantly move "back" to the contents page. Instead, users simply click a new content
level in the static frame.
Fixed interface elements. As mentioned previously, you can force clickable graphics,
logos, and other information to stay in one fixed portion of the screen, while the rest of
your document scrolls in another frame.
Better forms and results. Frames also enable you to create a form in one frame and
offer results in another frame. This is something we're beginning to see extensively with
Web search. With the search text box always available, you're free to change search
phrases or pinpoint your search more quickly, without moving back in the hierarchy of
the Web pages.
An HTML document that describes frame layout (called a frameset document) has a
different makeup than an HTML document without frames. A standard document has one HEAD
section and one BODY. A frameset document has a HEAD, and a FRAMESET in place of the
BODY.
The FRAMESET section of a document specifies the layout of views in the main user
agent window. In addition, the FRAMESET section can contain a NOFRAMES element to
provide alternate content for user agents that do not support frames or are configured not to
display frames.
Elements that might normally be placed in the BODY element must not appear before the first
FRAMESET element or the FRAMESET will be ignored.
On a typical page, <FRAMESET> is added like this:
<HTML>
<HEAD>
...HEAD markup...
</HEAD>
<FRAMESET>
...Frames and other HTML markup...
<NOFRAMES>
...No frames markup...
</NOFRAMES>
</FRAMESET>
</HTML>
The <FRAMESET> tag can accept two attributes: ROWS and COLS. Both attributes
accept either numerical values (size in pixels) or percentages, or a combination of both. The
value * can also be used to suggest that a particular row or column should take up the rest of the
page. The number of rows or columns is suggested by the number of values you give the
attribute. These attributes take the following format:
<FRAMESET ROWS="numbers,percentages,*" COLS="numbers,percentages,
*">
1>This example demonstrates how to make a vertical frameset with three different documents.
<html>
<frameset cols="25%,50%,25%">
<frame src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
<noframes>
<body>Your browser does not handle frames!</body>
</noframes>
</html>
2> This example demonstrates how to make a horizontal frameset with three different
documents.
<html>
<frameset rows="25%,50%,25%">
<frame noresize="noresize" src="frame_a.htm">
<frame src="frame_b.htm">
<frame src="frame_c.htm">
</frameset>
</html>
3> This example demonstrates how to make a frameset with three documents, and how to mix
them in rows and columns.
<html>
<frameset rows="50%,50%">
<frame src="frame_a.htm">
<FORM> Tag
The <FORM> element comes at the beginning of any form. When you create a <FORM>
element, you also define the script it uses and how it sends data, using the ACTION and
METHOD attributes:
ACTION-This attribute points the form to a URL that will accept the form's information
and do something with it. If you don't specify an ACTION, it sends the information back
to the same URL the page came from.
METHOD-This attribute tells the form how to send its information back to the script.
The most common method is POST, which sends all the information from the form
separately from the URL. The other option for METHOD is GET, which tacks the
information from the form to the end of the URL.
POST or GET?
Which one should you use if your forms-processing server supports both the POST and
GET methods? Here are some rules of thumb:
For best form-transmission performance, send small forms with a few short fields via the
GET method.
Because some server operating systems limit the number and length of command-line
arguments that can be passed to an application at once, use the POST method to send forms that
have many fields or that have long text fields.
If you are inexperienced in writing server-side forms-processing applications, choose
GET. The extra steps involved in reading and decoding POST-style transmitted parameters,
while not too difficult, may be more than you are willing to tackle.
If security is an issue, choose POST. GET places the form parameters directly in the
application URL, where they easily can be captured by network sniffers or extracted from a
server log file. If the parameters contain sensitive information like credit card numbers, you may
be compromising your users without their knowledge. While POST applications are not without
their security holes, they can at least take advantage of encryption when transmitting the
parameters as a separate transaction with the server.
If you want to invoke the server-side application outside the realm of a form, including
passing it parameters, use GET, because it lets you include form-like parameters as part of a
URL. POST-style applications, on the other hand, expect an extra transmission from the browser
after the URL.
<TEXTAREA> Tag
With <TEXTAREA>, you can provide a field for someone to enter multiple lines of
information. By default, a <TEXTAREA> form shows a blank field four rows long and 40
characters wide. You can make it any size you want by using the ROWS and COLS attributes in
the tag. You can also specify some default text by simply entering it between the <TEXTAREA>
and </TEXTAREA> tags.
The options for the <TEXTAREA> tag are as follows:
NAME-This is required. It defines the name for the data.
ROWS-This sets the number of rows in the field.
COLS-This sets the width of the field in characters.
Default text-Any text between the <TEXTAREA> and </TEXTAREA> tags is used as
default text and shows up inside the field.
<SELECT> Tag
The <SELECT> element shows a list of choices in either a pop-up menu or
a scrolling list. It's set up as an opening and closing tag with a number of choices listed in
between. Just like the <TEXTAREA> element, the <SELECT> tag requires you to define a
name. You can specify how many choices to show at once, using the SIZE attribute.
The options for the <SELECT> element are as follows:
NAME-This is required. It defines the name for the data.
SIZE-This attribute determines how many choices to show. If you omit SIZE or set it to
1, the choices are shown as a pop-up menu. If you set it to 2 or higher, it shows the
choices in a scroll box. If you set SIZE larger than the number of choices you have within
<SELECT>, a "nothing" choice is added. When the end user chooses this, it's returned as
an empty field.
MULTIPLE-This allows multiple selections. If you specify multiple, a scrolling window
displays-regardless of the number of choices or the setting of SIZE.
You present the choices the end user will make within the <SELECT> and </SELECT> tags.
The choices are listed inside the <OPTION> tag and don't allow any other HTML markup.
The options for the <OPTION> tag are the following:
VALUE-This is the value to be assigned for the choice, which is what is sent back to the
script and doesn't have to be the same as what is presented to the end user.
SELECTED-If you want one of the choices to be a default, use the SELECTED option
in the <OPTION> tag.
<INPUT> Tag
<INPUT>, unlike <TEXTAREA> and <SELECT>, is a single tag option for gathering
information. <INPUT> contains all of the other options for acquiring information, including
simple text fields, password fields, radio buttons, check boxes, and the buttons to submit and
reset the form.
The attributes for the <INPUT> tag are the following:
NAME This defines the name for the data. This field is required for all the types of
input except SUBMIT and CLEAR.
SIZE This is the size of the input field in number of characters for text or password.
MAXLENGTH This specifies the maximum number of characters to be allowed for a
text or password field.
VALUE For a text or password field, it defines the default text displayed. For a check
box or radio button, it specifies the value that will be returned to the server if the box or
button is selected. For the SUBMIT and RESET buttons, it defines the text inside the
button.
CHECKED This sets a check box or radio button on. It has no meaning for any other
type of <INPUT> tag.
TYPE This sets the type of input field you want to display. (See the types in the
following section.)
INPUT TYPE
The possible values for the INPUT TYPE attribute:
TEXT TEXT, the default input type, displays a simple line of text
PASSWORD PASSWORD, a modified TEXT field, displays typed characters as
bullets instead of the characters actually typed.
CHECKBOX CHECKBOX displays a simple check box that can be checked or
empty; use a check box when the choice is yes or no and doesn't depend on anything.
RADIO RADIO is a more complex version of a check box, allowing only one of a set
to be chosen. You can group radio buttons together using the NAME attribute; keep all
buttons in the same group under one NAME.
RESET RESET displays a push button with the preset function of clearing all the data
in the form to its original value.
SUBMIT SUBMIT displays a push button with the preset function of sending the data
in the form to the server to be processed.
Example:
1> This example demonstrates how to create check-boxes, radio button and simple drop down
box with pre-selected item on an HTML page.
<html><body>
<form action="">
I have a bike: <input type="checkbox" name="vehicle"
value="Bike">
<br>
I have a car: <input type="checkbox" name="vehicle"
value="Car">
<br>
I have an airplane: <input type="checkbox"
name="vehicle" value="Airplane">
<br>
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat"
selected="selected">Fiat</option>
<option value="audi">Audi</option>
</select>
<br>
<input type="submit" value="Submit">
</form>
</body></html>
Extra Code
<FORM NAME="display">
<A HREF="Forms.htm"
onMouseOver="document.display.msgbox.value='To the Form Examples
Main Page'" onMouseOut="document.display.msgbox.value=' ';">To
the Form Examples Main Page</A><BR> <A HREF="htmtitle.htm"
onMouseOver="document.display.msgbox.value=' To the Title Page'"
onMouseOut="document.display.msgbox.value=' ';">Title
Page</A><BR> <P> <INPUT TYPE="text" NAME="msgbox" SIZE="40">
</FORM>
An Introduction to DHTML
DHTML stands for Dynamic HTML.
DHTML is not a standard defined by the World Wide Web Consortium (W3C). DHTML
is a "marketing term" - used by Netscape and Microsoft to describe the new technologies the 4.x
generation browsers would support. DHTML is a combination of technologies used to create
dynamic Web sites. To most people DHTML means a combination of HTML 4.0, Style Sheets
and JavaScript.
W3C once said: "Dynamic HTML is a term used by some vendors to describe the
combination of HTML, style sheets and scripts that allows documents to be animated."
DOM
A standard object model for HTML it defines the objects and properties of all HTML
elements, and the methods (interface) to access them. In other words:
The HTML DOM is a standard for how to get, change, add, or delete HTML
elements.
Every part of a Web page is specified by the DOM and using its consistent naming
conventions you can access them and change their properties.
Scripts
Scripts written in either JavaScript or ActiveX are the two most common scripting
languages used to activate DHTML. You use a scripting language to control the objects specified
in the DOM.
XHTML
XHTML or HTML 4.x is used to create the page itself and build the elements for the CSS
and the DOM to work on. There is nothing special about XHTML for DHTML - but having valid
XHTML is even more important, as there are more things working from it than just the browser.
Features of DHTML
There are four primary features of DHTML:
1. Changing the tags and properties
2. Real-time positioning
3. Dynamic fonts (Netscape Communicator)
4. Data binding (Internet Explorer)
Cross-browser DHTML
Cross-browser refers to the ability for a website, web application, HTML construct or
client-side script to support all the web browsers. The term cross-browser is often confused with
multi-browser. Multi-browser means something works with several web browsers. Cross-
browser means something works with all version of all browser to have existed since the web
began. Thus cross-browser DHTML support all version of all browsers.
The code describes a block of text, which should be displayed 100 pixels from the top and to the
left from the top-left corner of the browser window.
In a Netscape Navigator 4 browser, you would move it right with the following JavaScript code:
document.layers['sample'].left = 200;
However, to accomplish the same thing in Internet Explorer 4 you need to do this:
document.all['sample'].style.left = 200;
In order for the code to work in both browsers and thus be cross-browser compatible, it needs to
written like this:
if (document.all)
document.all['sample'].style.left = 200;
else if (document.layers)
document.layers['sample'].left = 200;
Thank You