5 XML (Unit 2)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 40

WEB

TECHNOLOGY
Contents
 XML Introduction
 Differences between HTML and XML
 XML Related Technologies
 XML Attributes and Comments
 XML Validation
 DTD and XSD
 CSS and XSLT
 CDATA vs PCDATA
 XML Parsers: SAX and DOM
 DHTML
 Difference between HTML and DHTML
Extensible Markup Language (XML) is used to describe the data.
The XML standard is a flexible way to create information formats and
electronically share structured data via the public Internet, as well as
via corporate networks.
XML
XML stands for eXtensible Markup Language and it is used for storing and transferring data

• Xml was released in late 90’s.


• It was created to provide an easy to use and store self describing data(data that describes both its content and structure)
• XML became a W3C Recommendation on February 10, 1998.
• XML doesn’t depend on the platform and programming language( ie. platform independent & language independent)
• We can write a program in any language on any platform (OS) to send, receive or store data using XML.
• XML is not a replacement for HTML. It is different from HTML.
• XML focuses on data while HTML focuses on how the data looks.
• In HTML most of the tags are predefined while XML doesn’t have predefined tags. Need to define our own tags.
• XML is designed to carry data, not to display data.
Main Benefit
• Platform Independent and Language Independent
• Its international acceptance.

We can use it to take data from a program like Microsoft SQL, convert it into XML then share that XML with other
programs and platforms.

- Can communicate between two platforms which are generally very difficult.

- The main thing which makes XML truly powerful is its international acceptance.
- Many corporation use XML interfaces for databases, programming, office application mobile phones and
more. It is
due to its platform independent feature.
Features and Advantages of XML
XML is widely used in the era of web development. It is also used to simplify data storage and data sharing.

The main features or advantages of XML are given below:

1) XML separates data from HTML


HTML is not for dynamic data. With XML, data can be stored in separate XML files. This way we can focus on using
HTML/CSS for display and layout, and be sure that changes in the underlying data will not require any changes to the
HTML.

2) XML simplifies data sharing

Computer systems and databases contain data in incompatible formats while XML data is stored in plain text format. This
provides a software- and hardware-independent way of storing and sharing data by different applications.

3) XML simplifies data transport


Exchanging data between incompatible systems over the Internet is very time-consuming and challenging. But XML
greatly reduces this complexity, since the data (which is plain text format) can be read by different incompatible
applications.
4) XML simplifies Platform change
XML data is stored in text format. This makes it easier to expand or upgrade to new operating systems, new applications,
or new browsers, without losing data.

5) XML increases data availability


Different applications can access data from XML data sources. With XML, data can be available to all kinds of "reading
machines" (Handheld computers, voice machines, news feeds, etc), and make it more available for blind people, or
people with other disabilities.

Disadvantages of XML
Cons/drawback of using XML:

• XML requires a processing application.


• Its syntax is similar to another alternative 'text-based' data transmission formats, which is sometimes confusing.
• No intrinsic data type support
• The XML syntax is redundant.
• Does not allow the user to create his tags.
Differences between HTML and XML
SNo. HTML(Hyper Text Markup Language) XML(eXtensible Markup Language)
It is a software and hardware independent tool used to
1 Used to display data and focuses on how data looks. transport and store data. It focuses on what data is.
2 HTML is not a case sensitive language XML is case sensitive language

3 HTML is a markup language itself. Provides a framework to define markup languages.

4 HTML is static because it is used to display data. XML is dynamic because it is used to transport data.

5 Closing tag in optional Closing tag is mandatory

6 HTML has its own predefined tags. We can define tags according to our need.

7 HTML does not preserve white space. XML preserves white space.

8. Namespace not supported Supported.

9. File Extension .html or .htm File Extension is .xml

10. Size is comparatively large. Size is comparatively small


XML Related Technologies
Sno Technology Meaning Description
1) XHTML Extensible html It is a clearer and stricter version of XML. It belongs to the family of XML markup
languages. It was developed to make html more extensible and increase inter-
operability with other data.
2) XML DOM XML document object model It is a standard document model that is used to access and manipulate XML. It defines
the XML file in tree structure.
3) XSL Extensible style sheet language
it contain three i) It transforms XML into other formats, like html.
parts: ii) It is used for formatting XML to screen, paper etc.
i)XSLT (xsl iii) It is a language to navigate XML documents.
transform)
ii)XSL
iii)XPath

4) XQuery XML query language It is a XML based language which is used to query XML based data.
5) DTD Document type definition It is an standard which is used to define the legal elements in an XML document.

6) XSD XML schema definition It is an XML based alternative to dtd. It is used to describe the structure of an XML
document.
7) SOAP Simple object access protocol It is an acronym stands simple object access protocol. It is XML based protocol to let
applications exchange information over http. in simple words you can say that it is
protocol used for accessing web services.
8) WSDL web services description languages It is an XML based language to describe web services. It also describes the
functionality offered by a web service.
9) RSS Really simple syndication RSS is a XML-based format to handle web content syndication. It is used for fast
browsing for news and updates. It is generally used for news like sites.
(A) XML Example

XML documents create a hierarchical structure looks like a tree so it is known as XML Tree that starts at "the root" & branches to "the leaves".
Example of XML Document: XML documents uses a self-describing and simple syntax:

<?xml version="1.0" encoding="ISO-8859-1"?> // XML declaration. It defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/West
European
character set).
<note> //root element of the document
<to>Abhi</to>
<from>Avi</from>
//4 lines describe 4 child elements of the root (to, from, heading, & body).
<heading>Wishes</heading>
<body>Have a great life ahead!</body>
</note> // defines the end of the root element

• XML documents must contain a root element and it is "the parent" of all other elements.
• Elements in an XML document form a document tree.
• The tree starts at the root and branches to the lowest level of the tree. <root>
<child>
• All elements can have sub elements (child elements). <subchild>.....</subchild>
• The terms parent, child, and sibling are used to describe the relationships between elements. </child>
</root>
• 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).
(B) Example of XML: Books

TechBooks.xml

<bookstore> root element: <bookstore>


<book category="DATABASE"> All elements in the document are contained within <bookstore>
<title lang="en">Relational Algebra</title> The <book> element has 4 children: <title>,< author>, <year> and <price>.
<author>Seema</author>
<year>2005</year>
<price>300</price>
</book>
<book category="WEB TECHNOLOGIES">
<title lang="en">Java</title>
<author>Abhishek</author>
<year>2010</year>
<price>350</price>
</book>
</bookstore>
XML Attributes
• XML elements can have attributes. By the use of attributes we can add the information about the element.
• Attribute for an element is placed after the tag name in the start tag. We can add more than one attribute for a single element with
different attribute names.
• XML attributes enhance the properties of the elements. XML attributes must always be quoted(single or double quote).

<company name=“XYZ Holdings" location=“India">


<chairman>Mr. Abhishek</chairman> There are two attributes in the company element, i.e. name and location.
<gm>Mr. Vansh</gm>
</company>
<book>
<book category="computer">
Metadata should be stored as attribute and data should be stored as element. <author> A & B </author>
</book>

Data can be stored in attributes or in child elements. But there are some limitations in using attributes, over child elements.

Why should we avoid XML attributes :


• Attributes cannot contain multiple values but child elements can have multiple values.
• Attributes cannot contain tree structure but child element can.
• Attributes cannot describe structure but child elements can.
• Attributes values are not easy to test against a DTD, which is used to define the legal elements of an XML document.
XML Comments

XML comments are just like HTML comments. Although XML is known as self-describing data but sometimes XML
comments are necessary.

Syntax :
An XML comment should be written as: <!-- Write your comment-->
Don't use a comment before an XML declaration.
Comment can be used anywhere in XML document except within attribute value.

XML Comments Example


<?xml version="1.0" encoding="UTF-8" ?>
<!--Students marks are uploaded by months-->
<students>
<student>
<name>Ratan</name>
<marks>70</marks>
</student>
</students>
XML Tree Structure
• An XML document has a self descriptive structure which forms a tree structure and referred as an XML tree.
• Its tree structure makes easy to describe an XML document. It contains root element (as parent), child element and so on.
• It is very easy to traverse all succeeding branches and sub-branches and leaf nodes starting from the root.

Example of an XML document The tree-structure representation of given example:

<?xml version="1.0"?>
<college>
<student>
<firstname>Anu</firstname>
<lastname>Bhatt</lastname>
<contact>07899044992</contact>
<email>[email protected]</email>
<address>
<city>Haldwani</city>
<state>Uttarakhand</state>
<pin>201206</pin>
</address>
</student>
</college> Line 1: XML declaration( defines the XML version 1.0.
Line 2: Root element (college).
Line 3: Inside root element, there is one more
element: student
<student> : contains 5 branches-
<firstname>, <lastname>, <contact>,
XML Tree Rules

Used to represent the relationship of the elements. It shows if an element is a child or a parent of the other element.

(a) Descendants: If element A is contained by element B, then A is known as descendant of B.


In the figure below - "College" is the root element and all the other elements are the descendants of "College".

(b)Ancestors: The containing element which contains other elements is called "Ancestor" of other element.
In the figure below- Root element (College) is ancestor of all other elements.
XML Validation
- XML document ( a well- formed) can be validated against DTD or Schema.
- A well-formed XML document (valid XML document) is an XML document with correct syntax.

Valid XML document


It must be well formed (satisfy all the basic syntax condition). It should be behave according to predefined DTD or XML schema

Rules for well formed XML

• Must begin with the XML declaration.


• Must have one unique root element.
• All start tags of XML documents must match end tags.
• Tags are case sensitive.
• All elements must be closed.
• Elements must be properly nested.
• All attributes values must be quoted.
• XML entities must be used for special characters.
XML DTD
DTD stands for Document Type Definition.
It defines the legal building blocks of an XML document.

Main purpose:
To define the structure of an XML document. It contains a list of legal elements and attributes
DTD and XML schema both are used to form a well formed XML document.
An XML document is called "well-formed" if it contains the correct syntax.
A well-formed and valid XML document is one which have been validated against DTD.

XML schema

It is defined as an XML language


Uses namespaces to allow for reuses of existing definitions
Supports large number of built in data types and definition of derived data types
Valid and well-formed XML document with DTD
Example of well-formed and valid XML document: It follows all the rules of DTD.
employee.xml
In this example:
<?xml version="1.0"?> DOCTYPE declaration: refers to an external DTD file. Its content is shown below :
<!DOCTYPE employee SYSTEM "employee.dtd">
<employee> employee.dtd
<firstname>Abhineet</firstname>
<!ELEMENT employee (firstname, lastname, email)>
<lastname>Maitrey</lastname>
<!ELEMENT firstname (#PCDATA)>
<email>[email protected]</email>
<!ELEMENT lastname (#PCDATA)>
</employee>
<!ELEMENT email (#PCDATA)>

Description of DTD
<!DOCTYPE employee : root element of the document is employee.

<!ELEMENT employee: employee element contains 3 elements "firstname, lastname and email".

<!ELEMENT firstname: firstname element is #PCDATA typed. (parse-able data type).

<!ELEMENT lastname: lastname element is #PCDATA typed. (parse-able data type).

<!ELEMENT email: .email element is #PCDATA typed. (parse-able data type).


XML DTD with entity declaration
A doctype declaration can also define special strings that can be used in the XML file. An entity has three parts:

An ampersand (&)
An entity name
A semicolon (;)

Syntax to declare entity: <!


ENTITY entity-name "entity-
value">
Code to define the ENTITY in doctype declaration: author.xm
l
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE author [
<!ELEMENT author (#PCDATA)>
<!ENTITY sm "Seema Maitrey">
]>
<author>&sm;</author>

// Here, sm is an entity , used inside the author element. In such case, it will print the value of sm entity that is "Seema Maitrey"

Note: A single DTD can be used in many XML files.


XML CSS
Purpose of CSS in XML:
CSS (Cascading Style Sheets) can be used to add style and display information to an XML document.
It can format the whole XML document.

Link XML file with CSS : syntax: <?xml-stylesheet type="text/css" href="cssemployee.css"?>

XML CSS Example xml file using CSS and DTD : employee.xml

cssemployee.css
DTD file : employee.dtd
employee <?xml version="1.0"?>
{ <!ELEMENT employee (firstname,lastname,email)> <?xml-stylesheet type="text/css" href=“cssemployee.css"?>
background-color: pink; <!ELEMENT firstname (#PCDATA)> <!DOCTYPE employee SYSTEM "employee.dtd">
} <!ELEMENT lastname (#PCDATA)> <employee>
firstname,lastname,email <!ELEMENT email (#PCDATA)>
{ <firstname>Aviral</firstname>
font-size:25px; <lastname>Maitreyl</lastname>
display:block;
<email>[email protected]</email>
color: blue;
margin-left: 50px; </employee>
}

CSS is not generally used to format XML file. W3C recommends XSLT instead of CSS.
XML Schema – XSD (XML Schema Definition)

 The XML Schema language is also referred to as XML Schema Definition (XSD).
 XSD is used to define the possible structure and contents of an XML format.
 A validating parser can then check whether an XML instance document conforms to an XSD schema or a set of schemas.

• Similar to DTD, XML Schema is also used to check whether the given XML document is “well formed” and “valid”.
• XML schema is an alternative to DTD.
• An XML document is considered “well formed” and “valid” if it is successfully validated against XML Schema.
• The extension of Schema file is .xsd.

Why is it necessary to validate XML?


When sending data from a sender to a receiver, it is essential that both parts have the same "expectations" about the
content.
With XML Schemas, the sender can describe the data in a way that the receiver will understand.
XML Schema Example: XML file: tofro.xml XML Schema file: tofro.xsd
<?xml version="1.0"?>
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www
<MyBook> .w3.org/2001/XMLSchema" targetNamespace="http
<to>My Students</to>
s://www.beginnersbook.com" xmlns="https://www.b
<from>SM</from>
<subject>A Message to my students</subject> eginnersbook.com"
<message>Welcome to Mybook.com</message> elementFormDefault="qualified">
</MyBook> <!-- Root element “beginnersbook” is complexType-->
<xs:element name="beginnersbook">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
XML Schema Data types <xs:element name="from" type="xs:string"/>
In XML schema an element belongs to either of the following two types: <xs:element name="subject" type="xs:string"/>
(1) simpleType, (2) complexType <xs:element name="message" type="xs:string"/>
</xs:sequence>
(1) simpleType – Such type of element can contain text, they do not </xs:complexType>
contain other elements and cannot be left empty. </xs:element>
the elements- to, from, subject and message are simpleType element. </xs:schema>
2. complexType – Such type of element can contain attributes, other
elements, and text and can be left empty.
the element: beginnersbook is of type complexType because it contains
other elements.
DTD vs XSD
DTD provides less control on XML structure whereas XSD (XML schema) provides more control.
The important differences are given below:

SNo DTD XSD

1) DTD stands for Document Type Definition. XSD stands for XML Schema Definition.

2) Derived from SGML syntax. Are written in XML.

3) Doesn't support datatypes. Supports datatypes for elements and attributes.

4) Doesn't support namespace. Supports namespace.

5) Doesn't define order for child elements. Defines order for child elements.

6) Not extensible. It is extensible.


7) Provides less control on XML structure. Provides more control on XML structure.
Advantages of using XML Schema over DTD

1.Schema uses XML as language so don’t require to learn new syntax.

2. XML schema supports data types and namespaces.

3. XML parser can be used to parse the XML schema as well.

4. It is extensible i.e., we can reuse the schema in other schema.

5. More than one schemas can be referred in a single XML document.


CDATA vs PCDATA
CDATA
CDATA: (Unparsed Character data): CDATA contains the text which is not parsed further in an XML document.
Tags inside the CDATA text are not treated as markup and entities will not be expanded.

OP:
Example:

<?xml version="1.0"?> As the CDATA is used just after the element employee to make
<!DOCTYPE employee SYSTEM "employee.dtd"> the data/text unparsed, so it will give the output :
<employee>
<![CDATA[ <employee>
<firstname>Abhi</firstname> <![CDATA[ <firstname>Abhi</firstname>
<lastname>Maitrey</lastname> <lastname>Maitrey</lastname>
<email>[email protected]</email> <email>[email protected]</email> ]]>
]]> </employee>
</employee>
PCDATA
: PCDATA: (Parsed Character Data): PCDATA is the text that will be parsed by a parser.
Tags inside the PCDATA will be treated as markup and entities will be expanded.

Example:
OP
:
<?xml version="1.0"?> As the employee element contains 3 more elements 'firstname',
<!DOCTYPE employee SYSTEM 'lastname', and 'email', so it parses further to get the data/text
"employee.dtd"> of firstname, lastname and email to give the output as :
<employee>
<firstname>Abhi</firstname>
<lastname>Maitrey</lastname>
<email>[email protected]</email>
</employee> <employee>
<firstname>Abhi</firstname>
<lastname>Maitrey</lastname>
<email>[email protected]</email>
</employee>
XML Entities
In simple terms, entities are a way of representing special characters. Entities are also known as entity references.

Why XML Entities required?


• Some characters (such as ", & <, and so on) are reserved in XML. They are referred to as special characters and cannot be
directly used for other purposes.

• For example, the < and > symbols a used for tags. You cannot directly type from the keyboard for less than and greater
than signs. Instead, you need to use entities.

Following table shows some of the popular XML entities. Character Description Entity Name Usage
" Quotation mark (double quote) quot &quot;
& Ampersand amp &amp;
' Apostrophe (single quote) apos &apos;
< Less than sign lt &lt;
> Greater than sign gt &gt;
Example:
<friend>
<name>My friends are Vinny &amp; Anu.</name>
</friend>
XML Parsers
- It 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.

Working of XML parser :


Types of XML Parsers
These are the two main types of XML Parsers: (1) DOM (2) SAX
(1) XML DOM • DOM is an acronym stands for Document Object Model.
• It defines a standard way to access and manipulate documents.
• DOM is a programming API for HTML and XML documents.
• It defines the logical structure of documents and the way a document is accessed and manipulated.
• The DOM Parser implements a DOM API. This API is very simple to use.
Objective for DOM : To provide a standard programming interface that can be used in a wide variety of environments
and applications(used with any programming language).
• The XML DOM makes a tree-structure view for an XML document.
• We can access all elements through the DOM tree.
• We can modify or delete their content and also create new elements.
• The elements, their content (text and attributes) are all known as nodes.

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.
For example, consider this table, The DOM represents this table like this:
taken from an HTML document:

<TABLE>
<ROWS>
<TR>
<TD>A</TD>
<TD>B</TD>
</TR>
<TR>
<TD>C</TD>
<TD>D</TD>
</TR>
</ROWS>
</TABLE>
SAX (Simple API for XML)
A SAX Parser implements SAX API. This API is an event based API and less intuitive.

Features of SAX Parser


• It does not create any internal structure.
• Clients does not know what methods to call, they just overrides the methods of the API and place his own
code inside method.
• It is an event based parser, it works like an event handler in Java.

Advantages
1) It is simple and memory efficient.
2) It is very fast and works for huge documents.

Disadvantages
3) It is event-based so its API is less intuitive.
4) Clients never know the full information because the data is broken into pieces.
S.NO. SAX PARSER DOM PARSER
01. It is called a Simple API for XML Parsing. It is called as Document Object Model.

02. It’s an event-based parser. It stays in a tree structure.

03. SAX Parser is slower than DOM Parser. DOM Parser is faster than SAX Parser.

04. Best for the larger sizes of files. Best for the smaller size of files.

05. The internal structure can not be created by SAX Parser. The internal structure can be created by DOM Parser.

06. It is read-only. It can insert or delete nodes.

07. In the SAX parser backward navigation is not possible. In DOM parser backward and forward search is possible

08. Suitable for efficient memory. Suitable for large XML document.

09. A small part of the XML file is only loaded in memory. It loads whole XML documents in memory.
XSL and XSLT

• XSL stands for EXtensible Stylesheet Language. It is a styling language for XML just like CSS is a styling language for HTML.

• XSLT stands for XSL Transformation. It is used to transform XML documents into other formats (like transforming XML into
HTML).
• World Wide Web Consortium (W3C) developed XSL to understand and style an XML document, which can act as XML based
Stylesheet Language.
• An XSL document specifies how a browser should render an XML document.

Main parts of XSL Document

• XSLT: It is a language for transforming XML documents into various other types of documents.
• XPath: It is a language for navigating in XML documents.
• XQuery: It is a language for querying XML documents.
• XSL-FO: It is a language for formatting XML documents.
Working of XSLT:

• The XSLT stylesheet is written in XML format.


• It is used to define the transformation rules to be applied on the target XML document.
• The XSLT processor takes the XSLT stylesheet and applies the transformation rules on the target XML document and then it generates a
formatted document in the form of XML, HTML, or text format.
• At the end it is used by XSLT formatter to generate the actual output and displayed on the end-user.

Image representation:
Advantage of XSLT

• Provides an easy way to merge XML data into presentation because it applies user defined transformations to an XML
document and the output can be HTML, XML, or any other structured document.
• Provides Xpath to locate elements/attribute within an XML document. So it is more convenient way to traverse an XML
document rather than a traditional way, by using scripting language.
• It is template based. So it is more resilient to changes in documents than low level DOM and SAX.
• By using XML and XSLT, the application UI script will look clean and will be easier to maintain.
• XSLT can be used as a validation language as it uses tree-pattern-matching approach.
• We can change the output simply modifying the transformations in XSL files.
XSLT <xsl:for-each> Element
The XSLT <xsl:for-each> element is used to apply a template repeatedly for each node.

<xsl:for-each
select = Expression>
</xsl:for-each>

XSLT Element Example

creates a table of <employee> element with its attribute "id" and its child
<firstname>,<lastname><nickname> and <salary> by iterating over each employee.
Employee.xsl
Employee.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0"
<?xml version = "1.0"?> xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<?xml-stylesheet type = "text/xsl" href = "employee.xsl"?> <xsl:template match = "/">
<class> <html>
<body>
<employee id = "001"> <h2>Employee</h2>
<firstname>Aryan</firstname> <table border = "1">
<lastname>Gupta</lastname> <tr bgcolor = "pink">
<th>ID</th>
<nickname>Raju</nickname> <th>First Name</th>
<salary>30000</salary> <th>Last Name</th>
</employee> <th>Nick Name</th>
<th>Salary</th>
<employee id = "024"> </tr>
<firstname>Sara</firstname> <!-- for-each processing instruction
<lastname>Khan</lastname> Looks for each element matching the XPath expression
-->
<nickname>Zoya</nickname> <xsl:for-each select="class/employee">
<salary>25000</salary> <tr>
</employee> <td>
<!-- value-of processing instruction
<employee id = "056"> process the value of the element matching the XPath expression
<firstname>Peter</firstname> -->
<lastname>Symon</lastname> <xsl:value-of select = "@id"/>
</td>
<nickname>John</nickname> <td><xsl:value-of select = "firstname"/></td>
<salary>10000</salary> <td><xsl:value-of select = "lastname"/></td>
</employee> <td><xsl:value-of select = "nickname"/></td>
<td><xsl:value-of select = "salary"/></td>
</class> </tr>
</xsl:for-each>
</table> </body> </html> </xsl:template>
</xsl:stylesheet>
DHTML
• 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 4th version of IE (Internet Explorer) in 1997.

Components of Dynamic HTML

DHTML consists of the following four components or languages:

1. HTML 4.0
2. CSS
3. JavaScript
4. DOM.
Uses of DHTML

• It is used for designing the animated and interactive web pages that are developed in real-time.
• DHTML helps users by animating the text and images in their documents.
• It allows the authors for adding the effects on their pages.
• It also allows the page authors for including the drop-down menus or rollover buttons.
• This term is also used to create various browser-based action games.
• It is also used to add the ticker on various websites, which needs to refresh their content automatically.

Features of DHTML

• Its simplest and main feature is that we can create the web page dynamically.
• Dynamic Style is a feature, that allows the users to alter the font, size, color, and content of a web page.
• It provides the facility for using the events, methods, and properties. And, also provides the feature of code
reusability.
• It also provides the feature in browsers for data binding.
• With the help of DHTML, users can easily change the tags and their properties.
• The web page functionality is enhanced because the DHTML uses low-bandwidth effect.
Difference between HTML and DHTML

HTML (Hypertext Markup language) DHTML (Dynamic Hypertext Markup language)

1. HTML is simply a markup language. 1. DHTML is not a language, but it is a set of technologies
of web development.

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
extension in a system. 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 HTML,
the scripts or styles called as an HTML page. CSS, DOM, and JavaScript technologies called a DHTML
page.

7. This markup language does not need database connectivity. 7. This concept needs database connectivity because it interacts
with users.

You might also like