Unit-II Web Tech
Unit-II Web Tech
What is HTML?
</body>
</html>
Example Explained
The <!DOCTYPE html> declaration defines that this document is an HTML5 document
The <html> element is the root element of an HTML page
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is shown in the browser's title
bar or in the page's tab)
The <body> element defines the document's body, and is a container for all the visible
contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
The <h1> element defines a large heading
The <p> element defines a paragraph
The HTML element is everything from the start tag to the end tag:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
HTML Lists
Unordered lists and ordered lists are commonly used in HTML:
Unordered List
Ordered List
Style Description
Disc:
<ul style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Circle:
Square:
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
None:
<ul style="list-style-type:none">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
A type attribute can be added to an ordered list, to define the type of the marker:
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
Numbers:
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Uppercase Letters:
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Lowercase Letters:
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
NOTE: List items can contain new list, and other HTML elements, like images and links, etc.
Horizontal Lists
HTML lists can be styled in many different ways with CSS. One popular way, is to style a list to be
displayed horizontally:
Example
<!DOCTYPE html>
<html>
<head>
<style>
ul#menu li {
display:inline;
}
</style>
</head>
<body>
<h2>Horizontal List</h2>
<ul id="menu">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
<li>PHP</li>
</ul>
</body>
</html>
With a little extra style, you can make it look like a menu:
Example
ul#menu {
padding: 0;
}
ul#menu li {
display: inline;
}
ul#menu li a {
background-color: black;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover {
background-color: orange;
}
Topic Summary
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
HTML Attributes
Attributes provide additional information about HTML elements.
HTML Attributes
</body>
</html>
The first two letters specify the language (en). If there is a dialect, use two more letters (US).
When you move the mouse over the element, the title will be displayed as a tooltip.
Size Attributes
HTML images are defined with the <img> tag.
The filename of the source (src), and the size of the image (width and height) are all provided
as attributes:
Example
<img src="aktu.jpg" width="104" height="142">
The image size is specified in pixels: width="104" means 104 screen pixels wide.
You will learn more about images and the <img> tag later in this tutorial.
Lower case is the most common. Lower case is easier to type.At W3Schools we always use lower
case attribute names.
We Suggest: Always Quote Attribute Values
The HTML5 standard does not require quotes around attribute values.
The href attribute, demonstrated above, can be written as:
Example
<a href=http:// www.aktu.ac.in >
W3C recommends quotes in HTML4, and demands quotes for stricter document types like
XHTML.
Sometimes it is necessary to use quotes. This will not display correctly, because it contains a space:
Example
<p title=About aktu >
Using quotes are the most common. Omitting quotes can produce errors.At W3Schools we
always use quotes around attribute values.
Or vice versa:
<p title="John 'ShotGun' Nelson">
HTML Attributes
Below is an alphabetical list of some attributes often used in HTML:
Attribute Description
A complete list of all attributes for each HTML element, is listed in our: HTML Tag Reference.
HTML Links
Links are found in nearly all web pages. Links allow users to click their way from page to page.
The link text is the visible part (Visit our HTML tutorial).
Clicking on the link text, will send you to the specified address.
The link text does not have to be text. It can be an HTML image or any other HTML element.
Without a trailing slash on subfolder addresses, you might generate two requests to the server.
Many servers will automatically add a trailing slash to the address, and then create a new request.
Local Links
The example above used an absolute URL (A full web address).
A local link (link to the same web site) is specified with a relative URL (without http://www....).
Example
<a href="html_images.asp">HTML Images</a>
_self Opens the linked document in the same frame as it was clicked (this is default)
_top Opens the linked document in the full body of the window
If your webpage is locked in a frame, you can use target="_top" to break out of the frame:
Example
<a href="http:// www.aktu.ac.in /html/" target="_top">HTML5 tutorial!</a>
border:0 is added to prevent IE9 (and earlier) from displaying a border around the image.
Example
First, create a bookmark with the id attribute:
<h2 id="tips">Useful Tips Section</h2>
Then, add a link to the bookmark ("Useful Tips Section"), from within the same page:
<a href="#tips">Visit the Useful Tips Section</a>
Or, add a link to the bookmark ("Useful Tips Section"), from another page:
Example
<a href="html_tips.htm#tips">Visit the Useful Tips Section</a>
Summary Points
HTML Images
<!DOCTYPE html>
<html>
<body>
<h2>Spectacular Mountain</h2>
<img src="pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">
</body>
</html>
Always specify the width and height of an image. If width and height are not specified, the
page will flicker while the image loads.
Alternatively, you can use width and height attributes. Here, the values are specified in pixels by
default:
Example
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
Both the width, height, and style attributes are valid in the latest HTML5 standard.
We suggest you use the style attribute. It prevents styles sheets from changing the original size of
images:
Example
<!DOCTYPE html>
<html>
<head>
<style>
img {
width:100%;
}
</style>
</head>
<body>
<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
</body>
</html>
Animated Images
The GIF standard allows animated images:
Example
<img src="programming.gif" alt="Computer Man" style="width:48px;height:48px;">
Note that the syntax of inserting animated images is no different from non-animated images.
Add "border:0;" to prevent IE9 (and earlier) from displaying a border around the image.
Image Floating
Use the CSS float property to let the image float.
The image can float to the right or to the left of a text:
Example
<p>
<img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
The image will float to the right of the text.
</p>
<p>
<img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">
The image will float to the left of the text.
</p>
Image Maps
Use the <map> tag to define an image-map. An image-map is an image with clickable areas.
The name attribute of the <map> tag is associated with the <img>'s usemap attribute and
creates a relationship between the image and the map.
The <map> tag contains a number of <area> tags, that defines the clickable areas in the
image-map:
Example
<img src="planets.gif" alt="Planets" usemap="#planetmap" style="width:145px;height:126px;">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
Summary Points
HTML Tables
1 Eve Jackson 94
2 John Doe 80
3 Adam Johnson 67
4 Jill Smith 50
Remember to define borders for both the table and the table cells.
The <caption> tag must be inserted immediately after the <table> tag.
Summary Points
HTML Forms
Type Description
radio Defines radio button input (for selecting one of many choices)
Text Input
<input type="text"> defines a one-line input field for text input:
Example
<form>
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
This is how it will look like in a browser:
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20
characters.
Male
Female
Last name:
Mouse
Submit
or:
<form action="action_page.php" method="post">
GET is best suited to short amounts of data. Size limitations are set in your browser.
When to Use POST?
You should use POST:
If the form is updating data, or includes sensitive information (password).
POST offers better security because the submitted data is not visible in the page address.
Last name:
Mouse
Submit
Attribut Description
e
accept- Specifies the charset used in the submitted form (default: the page charset).
charset
action Specifies an address (url) where to submit the form (default: the submitting page).
autocom Specifies if the browser should autocomplete the form (default: on).
plete
method Specifies the HTTP method used when submitting the form (default: GET).
name Specifies a name used to identify the form (for DOM usage: document.forms.name).
novalida Specifies that the browser should not validate the form.
te
target Specifies the target of the address in the action attribute (default: _self).
Click Me!
Input Types
This chapter describes the input types of the <input> element.
Input Type: text
<input type="text"> defines a one-line input field for text input:
Example
<form>
First name:<br>
<input type="text" name="firstname">
<br>
Last name:<br>
<input type="text" name="lastname">
</form>
This is how the HTML code above will be displayed in a browser:
First name:
Last name:
User password:
Last name:
Mouse
Submit
If you omit the submit button's value attribute, the button will get a default text:
Example
<form action="action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit">
</form>
I have a bike
I have a car
color
date
datetime
datetime-local
email
month
number
range
search
tel
time
url
week
Input types, not supported by old web browsers, will behave as input type text.
Input Restrictions
Here is a list of some common input restrictions (some are new in HTML5):
Attribute Description
Example
<form>
Select your favorite color:
<input type="color" name="favcolor">
</form>
The <input type="range"> is used for input fields that should contain a value within a range.
Depending on browser support, the input field can be displayed as a slider control.
Example
<form>
<input type="range" name="points" min="0" max="10">
</form>
You can use the following attributes to specify restrictions: min, max, step, value.
The <input type="week"> allows the user to select a week and year.
Depending on browser support, a date picker can show up in the input field.
Example
<form>
Select a week:
<input type="week" name="week_year">
</form>
What is CSS?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to
simplify the process of making web pages presentable.
CSS handles the look and feel part of a web page. Using CSS, you can control the color of the
text, the style of fonts, the spacing between paragraphs, how columns are sized and laid out, what
background images or colors are used, as well as a variety of other effects.
CSS is easy to learn and understand but it provides a powerful control over the presentation of an
HTML document. Most commonly, CSS is combined with the markup languages HTML or
XHTML.
Advantages of CSS
CSS saves time - You can write CSS once and then reuse the same sheet in multiple
HTML pages. You can define a style for each HTML element and apply it to as many
web pages as you want.
Pages load faster - If you are using CSS, you do not need to write HTML tag attributes
every time. Just write one CSS rule of a tag and apply it to all the occurrences of that tag.
So, less code means faster download times.
Easy maintenance - To make a global change, simply change the style, and all the
elements in all the web pages will be updated automatically.
Superior styles to HTML - CSS has a much wider array of attributes than HTML, so you
can give a far better look to your HTML page in comparison to HTML attributes.
Multiple Device Compatibility - Style sheets allow content to be optimized for more
than one type of device. By using the same HTML document, different versions of a
website can be presented for handheld devices such as PDAs and cellphones or for
printing.
Global web standards – Now HTML attributes are being deprecated and it is being
recommended to use CSS. So it’s a good idea to start using CSS in all the HTML pages to
make them compatible with future browsers.
CSS Syntax
CSS syntax includes selectors, properties, values, declarations, declaration blocks, rulesets, at-
rules, and statements.
A selector is a code snippet used to identify the web page element or elements that are to be
affected by the styles.
A property is the aspect of the element that is to be affected. For example, color, padding,
margin, and background are some of the most commonly used CSS properties.
A value is used to define a property. For example, the property color might be given the value of
red like this: color: red;.
The combination of a property and a value is called a declaration.
In many cases, multiple declarations are applied to a single selector. A declaration block is the
term used to refer to all of the declarations applied to a single selector.
A single selector and the declaration block that follows it in combination are referred to as
a ruleset.
At-rules are similar to rulesets but begin with the @ sign rather than with a selector. The most
common at-rule is the @media rule which is often used to create a block of CSS rules that are
applied based on the size of the device viewing the web page.
h1 {
color: red;
font-size: 3em;
text-decoration: underline;
}
In this example, h1 is the selector. The selector is followed by a declaration block that includes three
declarations. Each declaration is separated from the next by a semicolon. The tabs and line breaks are
optional but used by most developers to make the CSS code more human-readable.
By using h1 as the selector, we are saying that every level 1 heading on the web page should follow
the declarations contained in this ruleset.
The ruleset contains three declarations:
color:red;
font-size: 3em;
text-decoration: underline;
color, font-size, and text-decoration are all properties. There are literally hundreds of CSS
properties you can use, but only a few dozen are commonly used.
We applied the values red, 3em, and underline to the properties we used. Each CSS property is
defined to accept values formatted in a specific way.
When to Use Classes
Use classes when there are multiple elements on a single web page that need to be styled. For
example, let’s say that you want links in the page header and footer to be styled in a consistent
manner, but not the same way as the links in the body of the page. To pinpoint those links you could
add a class to each of those links or the container holding the links. Then, you could specify the styles
using the class and be sure that they would only be applied to the links with that class attribute.
<style>
#nav {
background: lightgray;
overflow: auto;
}
#nav li {
float: left;
padding: 10px;
}
#nav li:hover {
background: gray;
}
</style>
<ul id="nav">
<li><a href="">Home</a></li>
<li><a href="">Shop</a></li>
<li><a href="">About Us</a></li>
<li><a href="">Contact Us</a></li>
</ul>
That code would produce a horizontal navigation menu with a light gray background beginning from
the left-hand side of the page. Each navigation item will have 10 pixels of spacing on all sides and
the background of each item will become darker when you allow your mouse to hover over it.
Any additional lists on the same web page would not be affected by that code.
#example-nav {
background: lightgray;
overflow: auto;
}
#example-nav li {
float: left;
padding: 10px;
}
#example-nav li:hover {
background: gray;
}
Inline styles
Internal stylesheets
External stylesheets
In the vast majority of cases, external stylesheets should be used. However, there are instances where
inline styles or internal stylesheets may be used.
Inline Styles
Inline styles are applied to specific HTML elements. The HTML attribute style is used to define
rules that only apply to that specific element. Here’s a look at the syntax for writing inline styles.
That code would cause just that heading to render with red underlined text and 10 pixels of padding
on all sides. There are very few instances where inline styles should be used. In nearly all cases they
should be avoided and the styles added to a stylesheet.
Internal Stylesheets
The earlier examples in this tutorial make use of internal stylesheets. An internal stylesheet is a block
of CSS added to an HTML document head element. The style element is used between the opening
and closing head tags, and all CSS declarations are added between the style tags.
We can duplicate the inline styles from the code above in an internal stylesheet using this syntax.
<head>
<style>
h1 {
color: red;
padding: 10px;
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Example Heading</h1>
</body>
That code would produce the same results as the inline styles. However, the benefit to using internal
stylesheets rather than inline styles is that all h1 elements on the page will be affected by the styles.
External Stylesheets
External stylesheets are documents containing nothing other than CSS statements. The rules defined
in the document are linked to one or more HTML documents by using the link tag within
the head element of the HTML document.
To use an external stylesheet, first create the CSS document.
/*************************************************
Save with a name ending in .css such as styles.css
*************************************************/
h1 {
color: red;
padding: 10px;
text-decoration: underline;
}
Now that we have an external stylesheet with some styles, we can link it to an HTML document
using the link element.
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Example Heading</h1>
</body>
When this HTML document is loaded the link tag will cause the styles in the file styles.css to be
loaded into the web page. As a result, all level 1 heading elements will appear with red text,
underlined, and with 10 pixels of padding applied to every side.
Introduction to XML
XML was designed to describe data.
HTML was designed to display data.
What is XML?
The note above is quite self-descriptive. It has sender and receiver information, it also has a heading
and a message body.
But still, this XML document does not DO anything. It is just information wrapped in tags. Someone
must write a piece of software to send, receive or display it.
XML Tree
XML documents form a tree structure that starts at "the root" and branches to "the leaves".
The first line is the XML declaration. It defines the XML version (1.0).
The next line describes the root element of the document (like saying: "this document is a note"):
<note>
The next 4 lines describe 4 child elements of the root (to, from, heading, and body):
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
And finally the last line defines the end of the root element:
</note>
You can assume, from this example, that the XML document contains a note to Tove from Jani.
Don't you agree that XML is pretty self-descriptive?
The terms parent, child, and sibling are used to describe the relationships between elements. Parent
elements have children. Children on the same level are called siblings (brothers or sisters).
All elements can have text content and attributes (just like in HTML).
Example:
The root element in the example is <bookstore>. All <book> elements in the document are contained
within <bookstore>.
The <book> element has 4 children: <title>,< author>, <year>, <price>.
XML Elements
An XML document contains XML Elements.
An XML element is everything from (including) the element's start tag to (including) the element's
end tag.
An element can contain:
other elements
text
attributes
or a mix of all of the above...
<bookstore>
<book category="CHILDREN">
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
In the example above, <bookstore> and <book> have element contents, because they contain other
elements. <book> also has an attribute (category="CHILDREN"). <title>, <author>, <year>, and
<price> have text contentbecause they contain text.
Naming Styles
There are no naming styles defined for XML elements. But here are some commonly used:
Camel case <firstName> Uppercase first letter in each word except the first
Let's imagine that we created an application that extracted the <to>, <from>, and <body> elements
from the XML document to produce this output:
MESSAGE
To: Tove
From: Jani
Don't forget me this weekend!
Imagine that the author of the XML document added some extra information to it:
<note>
<date>2008-01-10</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML DTD
An XML document with correct syntax is called "Well Formed".
An XML document validated against a DTD is "Well Formed" and "Valid".
XML DTD
The purpose of a DTD is to define the structure of an XML document. It defines the structure with a
list of legal elements:
<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
The DTD above is interpreted like this:
!DOCTYPE note defines that the root element of the document is note
!ELEMENT note defines that the note element must contain four elements: "to, from,
heading, body"
!ELEMENT to defines the to element to be of type "#PCDATA"
!ELEMENT from defines the from element to be of type "#PCDATA"
!ELEMENT heading defines the heading element to be of type "#PCDATA"
!ELEMENT body defines the body element to be of type "#PCDATA"
<!DOCTYPE note [
<!ENTITY nbsp " ">
<!ENTITY writer "Writer: Donald Duck.">
<!ENTITY copyright "Copyright: W3Schools.">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<footer>&writer; ©right;</footer>
</note>
An entity has three parts: an ampersand (&), an entity name, and a semicolon (;).
XML Schema
An XML Schema describes the structure of an XML document, just like a DTD.
An XML document with correct syntax is called "Well Formed".
An XML document validated against an XML Schema is both "Well Formed" and "Valid".
XML Schema
XML Schema is an XML-based alternative to DTD:
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
!DOCTYPE note defines that the root element of this document is note
!ELEMENT note defines that the note element must contain four elements:
"to,from,heading,body"
!ELEMENT to defines the to element to be of type "#PCDATA"
!ELEMENT from defines the from element to be of type "#PCDATA"
!ELEMENT heading defines the heading element to be of type "#PCDATA"
!ELEMENT body defines the body element to be of type "#PCDATA"
Elements
Attributes
Entities
PCDATA
CDATA
Elements
Elements are the main building blocks of both XML and HTML documents.
Examples of HTML elements are "body" and "table". Examples of XML elements could be "note"
and "message". Elements can contain text, other elements, or be empty. Examples of empty HTML
elements are "hr", "br" and "img".
Examples:
<body>some text</body>
<message>some text</message>
Attributes
Attributes provide extra information about elements.
Attributes are always placed inside the opening tag of an element. Attributes always come in
name/value pairs. The following "img" element has additional information about a source file:
<img src="computer.gif" />
The name of the element is "img". The name of the attribute is "src". The value of the attribute is
"computer.gif". Since the element itself is empty it is closed by a " /".
Entities
Some characters have a special meaning in XML, like the less than sign (<) that defines the start of
an XML tag.
Most of you know the HTML entity: " ". This "no-breaking-space" entity is used in HTML to
insert an extra space in a document. Entities are expanded when a document is parsed by an XML
parser.
The following entities are predefined in XML:
< <
> >
& &
" "
' '
PCDATA
PCDATA means parsed character data.
Think of character data as the text found between the start tag and the end tag of an XML element.
PCDATA is text that WILL be parsed by a parser. The text will be examined by the parser for
entities and markup.
Tags inside the text will be treated as markup and entities will be expanded.
However, parsed character data should not contain any &, <, or > characters; these need to be
represented by the & < and > entities, respectively.
CDATA
CDATA means character data.
CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as
markup and entities will not be expanded.
XML Parsers
An XML parser is a software library or package that provides interfaces for client applications to
work with an XML document. The XML Parser is designed to read the XML and create a way for
programs to use XML.
XML parser validates the document and check that the document is well formatted.
Let's understand the working of XML parser by the figure given below:
1. DOM
2. SAX
DOM (Document Object Model)
A DOM document is an object which contains all the information of an XML document. It is
composed like a tree structure. The DOM Parser implements a DOM API. This API is very simple to
use.
A DOM Parser creates an internal structure in memory which is a DOM document object and the
client applications get information of the original XML document by invoking methods on this
document object.
Advantages
1) It supports both read and write operations and the API is very simple to use.
2) It is preferred when random access to widely separated parts of a document is required.
Disadvantages
1) It is memory inefficient. (consumes more memory because the whole XML document needs to
loaded into memory).
2) It is comparatively slower than other parsers.
SAX (Simple API for XML)
A SAX Parser implements SAX API. This API is an event based API and less intuitive.
Dynamic HTML: -
DHTML stands for Dynamic Hypertext Markup language i.e., Dynamic HTML.
Dynamic HTML is not a markup or programming language but it is a term that combines the features of
various web development technologies for creating the web pages dynamic and interactive.
The DHTML application was introduced by Microsoft with the release of the 4 th version of IE (Internet Explorer)
in 1997.
Components of Dynamic HTML
o HTML 4.0
o CSS
o JavaScript
o DOM.
HTML 4.0
HTML is a client-side markup language, which is a core component of the DHTML. It defines the structure of a
web page with various defined basic elements or tags.
CSS
CSS stands for Cascading Style Sheet, which allows the web users or developers for controlling the style and
layout of the HTML elements on the web pages.
JavaScript
JavaScript is a scripting language which is done on a client-side. The various browser supports JavaScript
technology. DHTML uses the JavaScript technology for accessing, controlling, and manipulating the HTML
elements. The statements in JavaScript are the commands which tell the browser for performing an action.
DOM
DOM is the document object model. It is a w3c standard, which is a standard interface of programming for
HTML. It is mainly used for defining the objects and properties of all elements in HTML.
Uses of DHTML
o It is used for designing the animated and interactive web pages that are developed in real-time.
o DHTML helps users by animating the text and images in their documents.
o It allows the authors for adding the effects on their pages.
o It also allows the page authors for including the drop-down menus or rollover buttons.
o This term is also used to create various browser-based action games.
o It is also used to add the ticker on various websites, which needs to refresh their content automatically.
2. It is used for developing and creating web pages. 2. It is used for creating and designing the
animated and interactive web sites or pages.
3. This markup language creates static web pages. 3. This concept creates dynamic web pages.
4. It does not contain any server-side scripting code. 4. It may contain the code of server-side scripting.
5. The files of HTML are stored with the .html or .htm 5. The files of DHTML are stored with the .dhtm
extension in a system. extension in a system.
6. A simple page which is created by a user without using 6. A page which is created by a user using the
the scripts or styles called as an HTML page. HTML, CSS, DOM, and JavaScript technologies
called a DHTML page.
7. This markup language does not need database 7. This concept needs database connectivity
connectivity. because it interacts with users.
DHTML JavaScript
JavaScript can be included in HTML pages, which creates the content of the page as dynamic. We can easily
type the JavaScript code within the <head> or <body> tag of a HTML page. If we want to add the external
source file of JavaScript, we can easily add using the <src> attribute.
Following are the various examples, which describes how to use the JavaScript technology with the DHTML:
Document.write() Method
Example 1: The following example simply uses the document.write() method of JavaScript in the DHTML. In
this example, we type the JavaScript code in the <body> tag.
1. <HTML>
2. <head>
3. <title>
4. Method of a JavaScript
5. </title>
6. </head>
7. <body>
8. <script type="text/javascript">
9. document.write("JavaTpoint");
10. </script>
11. </body>
12. </html>
Output: