Dynamic HTML , or DHTML , is an umbrella term for a collection of technologies used to create interactive and animated websites [1] by using a combination of a static markup language(such as HTML ), a client-side scripting language (such as JavaScript ), a presentation definition language (such as CSS ), and the Document Object Model (DOM). [2] The application of DHTML was introduced by Microsoft with the release of Internet Explorer 4 in 1997.

Allows DHTML scripting languages to change variables in a web page’s definition language, qui in turn affects the look and function of otherwise “static” HTML page content, after- the page has-been fully loaded and viewing During the process. Thus the dynamic characteristic of DHTML is the way it functions while a page is viewed, not in its ability to generate a single page with each page load.

By contrast, a dynamic web page is a broader concept, covering any web page generated for each user, load occurrence, or specific variable values. This includes pages created by client-side scripting, and those created by server-side scripting (such as PHP , Perl , JSP, or ASP.NET ) where the web server generates content before sending it to the client.

DHTML is differentiated from Ajax by the fact that DHTML is still request / reload-based. With DHTML, there is not any interaction between the client and the server after the page is loaded; all processing happens in JavaScript on the client side. By contrast, an Ajax page uses the features of DHTML to initiate a request (or ‘subrequest’) to the server to perform additional actions. For example, if there are multiple tabs on a page, pure DHTML would be able to load the contents of all the tabs and then dynamically display only the one that is active, while AJAX could load each tab only when it is really needed.


DHTML makes it easier to achieve. In short words: scripting language is changing the DOM and page style.

Simply put, DHTML is the combination of HTML, CSS, and JavaScript offering ways to:

  • Animate text et images dans les document, independently moving any element from a starting point to any ending point, following the path taken by the user.
  • Embed a ticker or other dynamic display that automatically reflects its content, stock quotes, or other data.
  • Use a form to capture user input, and then process, verify and respond to that data without having to send data back to the server.
  • Include rollover buttons or drop-down menus.

A less common is to create browser-based action games. ALTHOUGH a number of games created using DHTML Were During the late 1990s and early 2000s, citation needed ] differences entre browsers made this difficulty: many technical Had To Be Implemented in code to enable the games to Work is multiple platforms. Recently browsers have been converging towards web standards , which has made the design of DHTML games more viable. These games can be played on all major browsers and they can also be used for Plasma for KDE , Widgets for macOS and Gadgets for Windows Vista , which are based on DHTML code.

The term “DHTML” has been developed in the past few years and has been developed with the help of various web browsers. DHTML may be referred to as unobtrusive JavaScript coding (DOM scripting), in an effort to place an emphasis on agreed-upon best practices while allowing similar effects in an accessible, standard-compliant way .

DHTML support with extensive DOM access was introduced with Internet Explorer 4.0 . Although there was a basic dynamic system with Netscape Navigator 4.0 , not all HTML elements were represented in the DOM. When DHTML-style techniques became widespread, varying degrees of support among web browsers for the technologies involved made it difficult to develop and debug . Development became easier when Internet Explorer 5.0+ , Mozilla Firefox2.0+, and Opera 7.0+ adopted a shared DOM inherited from ECMAScript .

More recently, JavaScript libraries Such As jQuery -have abstracted away Many of the day-to-day Difficulties in cross-browser DOM manipulation.

Structure of a web page

See also: DOM events

Typically a web page using DHTML is set up in the following way:

<! DOCTYPE html>
< html lang = "in" >
 < head >
 < meta charset = "utf-8" >
 < title > DHTML example </ title >
 </ head >
 < body >
 < div id = "navigation" > </ div >
 < script >
 function init () {
 var myObj = document .getElementById ("navigation" );
 // ... manipulate myObj
 window . onload = init ;
 </ script >
 <! -
 Often the code is stored in an external file; this is done
 by linking the file that contains the JavaScript.
 This is useful when multiple pages use the same script:
 < script src = "myjavascript.js" > </ script >
 </ body >
</ html >

Example: Displaying an additional block of text

The following code illustrates an often-used function. An additional part of a web page will be displayed if the user requests it.

<! doctype html>
< meta charset = "utf-8" >
< title > Using a DOM function </ title >
< style >
 a { background-color : #eee ; }
 a : hover { background : # ff0 ; }
 # toggleMe { background : #cfc ; display : none ; margin : 30 px 0 ; padding: 1 em ; }
</ Style >
< h1 > Using a DOM function </ h1 >
< h2 > < a id = "showhide" href = "#" > Show paragraph </ a > </ h2 >
< p id = "toggleMe" > This is the paragraph that is only displayed on request. < p > The general flow of the document continues. < script >
 changeDisplayState ( id ) {
 var d = document . getElementById ( 'showhide' ),
 e = document . getElementById ( id );
 if ( e . Style . Display === 'none' || e . Style . Display === '' ) {
 e . style . display = 'block' ;
 d . innerHTML = 'Hide paragraph' ;
 } else {
 e . style . display = 'none' ;
 d . innerHTML = 'Show paragraph' ;
 document . getElementById ( 'showhide' ). addEventListener ( 'click' , function ( e ) {
 e . preventDefault ();
 changeDisplayState ( 'toggleMe' );
</ script >

Document Object Model

Main article: Document Object Model

DHTML is not a technology in and of itself; rather, it is the product of three related and complementary technologies: HTML, Cascading Style Sheets (CSS), and JavaScript . To allow scripts and components to access features of HTML and CSS, the contents of the document are known as Document Object Model (DOM).

The DOM API is the foundation of DHTML, providing a structured interface that allows access and manipulation of virtually anything in the document. The HTML elements in the document are available as a hierarchical tree of individual objects. The text between elements is also available through DOM properties and methods.

The DOM is providing access to user actions such as pressing and clicking the mouse. You can intercept and process these and other events by creating event handler functions and routines. The eventual handler receives control of each action, including using the DOM to change the document.

Dynamic styles

Dynamic styles are a key feature of DHTML. By using CSS, you can quickly change the appearance and formatting of elements in a document without adding or removing elements. This helps keep your documents small and the scripts that handle the document fast.

The object model provides programmatic access to styles. This means you can change inline styles on individual elements.

Inline styles are CSS style assignments that have been applied to an element using the style attribute. You can examine and set these styles by retrieving the object style for an individual element. For example, to highlight the text in a heading when the user moves the mouse pointer over it, you can use the style object to enlarge and change its color, as shown in the following simple example.

<! DOCTYPE html>
< html lang = "en" >
 < head >
 < charset meta = "utf-8" > < title > Dynamic Styles </ title > < style > ul { display : none ; } </ style > </ head > < body > < h1 id = "firstHeader" > Welcome to Dynamic HTML <
 < P > < a id = "clickableLink" href = "#" > Dynamic styles are a key feature of DHTML. </ a > </ p >
 < ul id = "unorderedList" >
 < li > Change the color, size, and typeface of text </ li >
 < li > Show and hide text </ li >
 < li > And much, much more </ li >
 > We've only just begun! </ p >
 < script >
 function showMe () {
 document . getElementById ( "firstHeader" ). style . color = "# 990000" ;
 document . getElementById ( "unorderedList" ). style . display = "block" ;
 document . getElementById ( "clickableLink" ). addEventListener ( "click" function ( e ) {
 e . preventDefault ();
 showMe ();
 </ script >
 </ body >
</ html >

See also

  • Dynamic web page
  • Dynamic Cascading Style Sheets


  1. Jump up^ http://www.w3.org/DOM/#why
  2. Jump up^ http://www.w3.org/Style/#dynamic