• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » What is Dynamic HTML (DHTML) – Working Examples

By Abhishek Ghosh April 21, 2024 11:01 pm Updated on April 21, 2024

What is Dynamic HTML (DHTML) – Working Examples

Advertisement

The terms DHTML or dynamic HTML refers to certain web design methods in which a web page itself is changed during the display of it, triggered by events such as user input. The term “dynamic” refers to the idea that these events can also occur multiple times when a page is displayed. Examples of dynamic display effects include:

  • The appearance (“unfolding”) of a menu
  • The highlighting of a text
  • The ability to drag and drop objects on the screen
  • Automatically populate form fields depending on other fields
  • Effects similar to those of client-side applications

As early as the mid-1990s, the scripting languages JavaScript in Netscape Navigator and JScript in Microsoft Internet Explorer made it possible to modify websites based on events. At that time, the term DHTML was used to refer to these capabilities of the program versions of the time. Due to the standardization of the Document Object Model and the bursting of the dot-com bubble at the time, the term fell out of fashion.

 

Techniques of Dynamic HTML

 

Dynamic HTML includes the following techniques:

Advertisement

---

  • HTML for Document Writing
  • A client-side scripting language, mostly JavaScript
  • An interface for modifying and extending the HTML document, today the Document Object Model (DOM) is mainly used
  • XMLHttpRequest to exchange data between the browser and a remote HTTP server (see also Ajax).
  • Fetch API to exchange data between the browser and a remote HTTP server.
  • A format for transmitting structured data, such as XML or JSON

It is not necessary to use all the techniques in this list in a document (especially those for data transfer after the first load) in order to call it an application of dynamic HTML.

 

Use Cases of Dynamic HTML

 

Interactive Forms

Using JavaScript, you can create forms that dynamically update based on user input. For example, you can create a form where the options in one dropdown menu change based on the selection made in another dropdown menu.

Animated Effects

DHTML allows for the creation of animated effects such as fading, sliding, or expanding elements on a web page. For instance, you can create a slideshow where images transition smoothly from one to another.

Real-time Data Updates

Websites that display real-time data, such as stock tickers or live news feeds, utilize DHTML to dynamically update the content without requiring the user to refresh the page manually. JavaScript can fetch data from a server periodically and update the DOM accordingly.

Drag-and-Drop Interactions

DHTML enables drag-and-drop interactions, where users can move elements around on a web page using their mouse. This can be useful for creating interactive interfaces such as sortable lists or draggable elements in a game.

Form Validation

JavaScript can be used to perform client-side form validation, providing immediate feedback to users when they fill out a form incorrectly without needing to submit it first. This enhances the user experience by reducing the number of server requests and page reloads.

 

Code Examples of Dynamic HTML

 

Interactive Button Click:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<head>
  <title>Dynamic HTML Example</title>
  <script>
    function changeText() {
      document.getElementById("demo").innerHTML = "Text changed!";
    }
  </script>
</head>
<body>
 
<p id="demo">Click the button to change this text.</p>
<button onclick="changeText()">Change Text</button>
 
</body>
</html>

See the Pen
Untitled
by Abhishek Ghosh (@abhishekghosh-the-encoder)
on CodePen.

In this example, clicking the button triggers the changeText() function, which updates the text inside the p element with the id “demo”.

Dynamic Image Change:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<head>
  <title>Dynamic HTML Example</title>
  <script>
    function changeImage() {
      document.getElementById("image").src = "new_image.jpg";
    }
  </script>
</head>
<body>
 
<img id="image" src="old_image.jpg" alt="Old Image">
<button onclick="changeImage()">Change Image</button>
 
</body>
</html>

Clicking the button in this example changes the src attribute of the img element, replacing the old image with a new one.

Real-time Clock:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>
<head>
  <title>Dynamic HTML Example</title>
  <script>
    function updateClock() {
      var now = new Date();
      var time = now.toLocaleTimeString();
      document.getElementById("clock").innerHTML = time;
    }
 
    // Update the clock every second
    setInterval(updateClock, 1000);
  </script>
</head>
<body onload="updateClock()">
 
<p>The current time is: <span id="clock"></span></p>
 
</body>
</html>

See the Pen
Untitled
by Abhishek Ghosh (@abhishekghosh-the-encoder)
on CodePen.

This example displays a real-time clock that updates every second. The updateClock() function retrieves the current time and updates the content of the element with the id “clock” accordingly. The setInterval() function is used to call updateClock() every 1000 milliseconds (1 second).

These are just a few simple examples of how JavaScript can be used to dynamically modify HTML elements on a web page. There are countless other possibilities for creating dynamic and interactive web content using DHTML techniques.

 

Criticism and disadvantages

 

Dynamic HTML is often used for effect-oriented functions where the benefit is not clearly visible and which are more likely to be distracting.

What is Dynamic HTML DHTML - Working Examples

In the early days, DHTML could only be implemented via browser-specific so-called DHTML models, which were not compatible with each other. As a result, some DHTML pages on certain browsers resulted in errors. This reputation continues to this day. For this reason, the term DOM scripting is used today to distinguish standards-compliant DHTML from browser-specific variants.

Dynamic HTML sometimes places high demands on the browser’s JavaScript capabilities, which are only met by the newer generations of browsers. If the use of JavaScript is disabled, for example for security reasons, dynamic HTML cannot be used. In addition, accessibility may deteriorate for users who have to resort to alternative input or output methods due to physical limitations. However, it is possible to use dynamic HTML in such a way that it is only used by browsers that can handle it. The rest of the users can then use the website as if it were not using dynamic HTML at all.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to What is Dynamic HTML (DHTML) – Working Examples

  • Cheapest Arduino LED Clock With Arduino Clone at $8

    Here is Cheapest Arduino LED Clock Which With Arduino Clone Will Cost $8 To You. It Is Really Usable LED Clock For Any Purpose, Not For Fun.

  • Best Alarm Clock Apps for Android Tablets and Phones

    Best Alarm Clock Apps lists the Android Apps those can be to used as alarm clock. The featured alarm clock apps differ in part by their functions.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • Set up your own alarm clock using Windows 7 Task Scheduler

    You can set up your own alarm clock using Windows 7 Task Scheduler, without the need of any third party program. Here is a small tutorial on how you can set up alarm clock in Windows 7.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

vpsdime

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Cloud-Powered Play: How Streaming Tech is Reshaping Online GamesSeptember 3, 2025
  • How to Use Transcribed Texts for MarketingAugust 14, 2025
  • nRF7002 DK vs ESP32 – A Technical Comparison for Wireless IoT DesignJune 18, 2025
  • Principles of Non-Invasive Blood Glucose Measurement By Near Infrared (NIR)June 11, 2025
  • Continuous Non-Invasive Blood Glucose Measurements: Present Situation (May 2025)May 23, 2025
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2026 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy