SlideShare a Scribd company logo
2
Most read
4
Most read
Structured graphics
Creating structured graphics in DHTML (Dynamic HTML) typically involves using HTML, CSS, and
JavaScript to manipulate graphical elements on a webpage. While DHTML itself does not have built-in
graphic capabilities like SVG or canvas, you can use a combination of HTML elements and scripting to
create dynamic, structured graphics.
You can use HTML elements like div, span, img, or even SVG elements to represent graphical
components. For example, a div can be styled to appear as a rectangle or circle.
CSS is used for styling elements to create shapes, colors, and positions that represent graphics. You can
use border-radius, background-color, width, and height properties for shapes.
JavaScript is used to manipulate the DOM (Document Object Model) and make the graphics interactive
or animated. You can change properties dynamically, such as position, size, and color, based on user
input or time intervals
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Structured Graphics in DHTML</title>
<style>
/* Styling the circle */
#circle {
width: 100px;
height: 100px;
border-radius: 50%; /* Make it round */
background-color: blue;
position: absolute;
left: 100px;
top: 100px;
}
</style>
</head>
<body>
<div id="circle"></div>
<script>
// JavaScript to change the circle's position and color
let circle = document.getElementById("circle");
let colors = ["blue", "green", "red", "yellow"];
let colorIndex = 0;
// Change color every 1 second
setInterval(() => {
circle.style.backgroundColor = colors[colorIndex];
colorIndex = (colorIndex + 1) % colors.length;
}, 1000);
// Move the circle around every 2 seconds
let x = 100;
let y = 100;
setInterval(() => {
x += 10;
y += 10;
circle.style.left = x + "px";
circle.style.top = y + "px";
}, 2000);
</script>
</body>
</html>
If you want more complex graphics, such as shapes, lines, or animations, you might want to use the
<canvas> element, which allows you to draw 2D graphics with JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Graphics in DHTML</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>
<script>
// Accessing the canvas element and its context
let canvas = document.getElementById("myCanvas");
let ctx = canvas.getContext("2d");
// Drawing a rectangle
ctx.fillStyle = "blue";
ctx.fillRect(50, 50, 150, 100);
// Drawing a line
ctx.beginPath();
ctx.moveTo(50, 50);
ctx.lineTo(200, 150);
ctx.strokeStyle = "red";
ctx.stroke();
</script>
</body>
</html>
Active controls
Active controls in DHTML (Dynamic HTML) refer to interactive elements on a webpage that can be
manipulated using HTML, CSS, and JavaScript to create dynamic, user-driven experiences. These controls
include things like buttons, input fields, dropdowns, sliders, and other elements that respond to user
actions, events, or changes.
In DHTML, "active" refers to the ability of these controls to respond to events like mouse clicks, keyboard
input, or page load, and update the page dynamically without requiring a full page reload. JavaScript
plays a critical role in enabling this interactivity, often by adding event listeners that respond to actions
like click, mouseover, change, etc.
Buttons
Buttons are one of the simplest active controls in DHTML. They can trigger actions when clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Button Example</title>
<script>
function showAlert() {
alert("Button clicked!");
}
</script>
</head>
<body>
<button onclick="showAlert()">Click Me</button>
</body>
</html>
The <button> element is used here, and the onclick event is used to trigger a JavaScript function when
the button is clicked.
showAlert() is a JavaScript function that displays an alert when the button is clicked.
Text Input (Form Controls)
Text input fields are interactive and can be used for user input. You can capture their value and take
action based on that.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Text Input Example</title>
<script>
function displayInputValue() {
let inputValue = document.getElementById("userInput").value;
alert("You entered: " + inputValue);
}
</script>
</head>
<body>
<input type="text" id="userInput" placeholder="Enter something here">
<button onclick="displayInputValue()">Submit</button>
</body>
</html>
The <input> element allows users to enter text, and the value property is used to retrieve the text
inputted by the user.
The displayInputValue() function displays the input value when the button is clicked.
Dropdown (Select Box)
A dropdown is another active control, which lets users select an option from a list.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Dropdown Example</title>
<script>
function showSelectedOption() {
let selectedOption = document.getElementById("fruitSelect").value;
alert("You selected: " + selectedOption);
}
</script>
</head>
<body>
<select id="fruitSelect" onchange="showSelectedOption()">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
</select>
</body>
</html>
The <select> element creates a dropdown menu with options. The onchange event triggers when the
user selects an option, and the value of the selected option is retrieved using JavaScript.
Checkbox
Checkboxes are used for binary (yes/no) selections. They can be toggled on and off.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Checkbox Example</title>
<script>
function checkStatus() {
let checkbox = document.getElementById("agreeCheckbox");
if (checkbox.checked) {
alert("You agreed to the terms!");
} else {
alert("You did not agree to the terms.");
}
}
</script>
</head>
<body>
<input type="checkbox" id="agreeCheckbox"> I agree to the terms and conditions
<button onclick="checkStatus()">Submit</button>
</body>
</html>
The <input type="checkbox"> allows users to toggle between checked and unchecked states. The
checked property is used in JavaScript to determine the checkbox's state.
The checkStatus() function displays an alert based on whether the checkbox is checked or not.
Slider (Range Input)
Sliders let users select a value from a range. This is particularly useful for adjusting settings like volume or
brightness.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Slider Example</title>
<script>
function updateSliderValue() {
let sliderValue = document.getElementById("volumeSlider").value;
document.getElementById("volumeOutput").innerText = "Volume: " + sliderValue;
}
</script>
</head>
<body>
<input type="range" id="volumeSlider" min="0" max="100" value="50" oninput="updateSliderValue()">
<p id="volumeOutput">Volume: 50</p>
</body>
</html>
The <input type="range"> creates a slider. The oninput event triggers every time the user moves the
slider, and the slider's value is retrieved and displayed dynamically.
Radio Buttons
Radio buttons allow users to choose between multiple options, but only one option can be selected at a
time.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Active Radio Button Example</title>
<script>
function showSelectedRadio() {
let radios = document.getElementsByName("color");
for (let radio of radios) {
if (radio.checked) {
alert("You selected: " + radio.value);
}
}
}
</script>
</head>
<body>
<input type="radio" name="color" value="Red"> Red<br>
<input type="radio" name="color" value="Green"> Green<br>
<input type="radio" name="color" value="Blue"> Blue<br>
<button onclick="showSelectedRadio()">Submit</button>
</body>
</html>
Audio Controls:
To embed an audio file in an HTML document, you can use the <audio> element. This element
allows you to embed sound content in your page, such as music, a podcast, or any other audio
file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audio Example</title>
</head>
<body>
<h1>Listen to this audio</h1>
<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
<audio>: This is the container element for audio.
controls: This attribute adds built-in controls to the audio player, such as play, pause, volume,
and seek bar.
<source>: Specifies the path to the audio file and its type. In this case, it's an MP3 file
(audiofile.mp3), but you can also use other formats like .ogg, .wav, etc.
The text "Your browser does not support the audio element" will display if the browser doesn't
support the <audio> tag.
Radio buttons with the same name attribute form a group, allowing only one option to be selected. The
showSelectedRadio() function checks which radio button is selected and displays it.
Video Controls:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Example</title>
</head>
<body>
<h1>Watch this video</h1>
<!-- Video Element -->
<video id="myVideo" width="640" height="360" controls>
<source src="https://www.youtube.com/watch?
v=plPnI_rVG9Q&list=RDplPnI_rVG9Q&start_radio=1" type="video/mp4">
<source src="video.ogg" type="video/ogg">
Your browser does not support the video element.
</video>
<!-- JavaScript to Control the Video -->
<button onclick="playVideo()">Play</button>
<button onclick="pauseVideo()">Pause</button>
<button onclick="changeVolume(0.5)">Set Volume to 50%</button>
<script>
// Get the video element
const video = document.getElementById('myVideo');
// Play video
function playVideo() {
video.play();
}
// Pause video
function pauseVideo() {
video.pause();
}
// Change volume
function changeVolume(volume) {
video.volume = volume; // volume is between 0 and 1
}
</script>
</body>
</html>
Navigator Object:
The JavaScript navigator object is used for browser detection. It can be used to get browser information
such as appName, appCodeName, userAgent etc.
The navigator object is the window property, so it can be accessed by:
window.navigator
No. Property Description
1 appName returns the name
2 appVersion returns the version
3 appCodeName returns the code name
4 cookieEnabled
returns true if cookie is
enabled otherwise false
5 userAgent returns the user agent
6 language
returns the language. It is
supported in Netscape and
Firefox only.
7 userLanguage
returns the user language. It
is supported in IE only.
8 plugins
returns the plugins. It is
supported in Netscape and
Firefox only.
9 systemLanguage
returns the system language.
It is supported in IE only.
<script>
document.writeln("<br/>navigator.appCodeName: "+navigator.appCodeName);
document.writeln("<br/>navigator.appName: "+navigator.appName);
document.writeln("<br/>navigator.appVersion: "+navigator.appVersion);
document.writeln("<br/>navigator.cookieEnabled: "+navigator.cookieEnabled);
document.writeln("<br/>navigator.language: "+navigator.language);
document.writeln("<br/>navigator.userAgent: "+navigator.userAgent);
document.writeln("<br/>navigator.platform: "+navigator.platform);
document.writeln("<br/>navigator.onLine: "+navigator.onLine);
</script>
Screen Object:
<script>
document.writeln("<br/>screen.width: "+screen.width);
document.writeln("<br/>screen.height: "+screen.height);
document.writeln("<br/>screen.availWidth: "+screen.availWidth);
document.writeln("<br/>screen.availHeight: "+screen.availHeight);
document.writeln("<br/>screen.colorDepth: "+screen.colorDepth);
document.writeln("<br/>screen.pixelDepth: "+screen.pixelDepth);
</script>
HTML <meta> tag
HTML <meta> tag is used to represent the metadata about the HTML document. It specifies page
description, keywords, copyright, language, author of the documents, etc.
The metadata does not display on the webpage, but it is used by search engines, browsers and other
web services which scan the site or webpage to know about the webpage.
With the help of meta tag, you can experiment and preview that how your webpage will render on the
browser.
The <meta> tag is placed within the <head> tag, and it can be used more than one times in a document.
1. <meta charset="utf-8">
It defines the character encoding. The value of charset is "utf-8" which means it will support to display
any language.
2. <meta name="keywords" content="HTML, CSS, JavaScript, Tutorials">
It specifies the list of keyword which is used by search engines.
3. <meta name="description" content="Courses available in Avanthi Colleges">
It defines the website description which is useful to provide relevant search performed by search
engines.
4. <meta name="author" content="thisauthor">
It specifies the author of the page. It is useful to extract author information by Content management
system automatically.
5. <meta name="refresh" content="50">
It specifies to provide instruction to the browser to automatically refresh the content after every 50sec
(or any given time).
6. <meta http-equiv="refresh" content="5; url=https://avanthimca.ac.in/infra">
In the above example we have set a URL with content so it will automatically redirect to the given page
after the provided time.
7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
It specifies the viewport to control the page dimension and scaling so that our website looks good on all
devices. If this tag is present, it indicates that this page is mobile device supported.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="HTML, CSS, JavaScript, Tutorials">
<meta name="description" content="Courses available in Avanthi college">
<meta name="author" content="thisauthor">
<meta http-equiv="refresh" content="5; url=https://avanthimca.ac.in/infra">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2>Example of Meta tag</h2>
<p>This example shows the use of meta tag within an HTML document</p>
</body>
</html>

More Related Content

Similar to Structured Graphics in dhtml and active controls.docx (20)

PDF
fuser interface-development-using-jquery
Kostas Mavridis
 
PPTX
Rohit&kunjan
Rohit Patel
 
PDF
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
 
ODP
Html5
prithag92
 
PDF
Introduction to HTML5
Gil Fink
 
ODP
Graphics & Animation with HTML5
Knoldus Inc.
 
PPTX
HTML5: An Overview
Nagendra Um
 
PDF
HTML5 New and Improved
Timothy Fisher
 
PDF
HTML5 and CSS3 refresher
Ivano Malavolta
 
PDF
GDG-USAR Tech winter break 2024 USAR.pdf
raiaryan174
 
PPTX
About Best friends - HTML, CSS and JS
Naga Harish M
 
PPTX
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Syed Moosa Kaleem
 
PDF
Building a Better Web with HTML5 and CSS3
Karambir Singh Nain
 
ODP
Html5
mikusuraj
 
PDF
Html5 intro
Kevin DeRudder
 
PDF
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
 
PPTX
HTML5: The Future of Web Development with IE9, IE10 and Windows 8
Shaymaa
 
PPT
HTML5
mohitrana1641993
 
PDF
lect4
tutorialsruby
 
PDF
lect4
tutorialsruby
 
fuser interface-development-using-jquery
Kostas Mavridis
 
Rohit&kunjan
Rohit Patel
 
HTML5 & CSS3 refresher for mobile apps
Ivano Malavolta
 
Html5
prithag92
 
Introduction to HTML5
Gil Fink
 
Graphics & Animation with HTML5
Knoldus Inc.
 
HTML5: An Overview
Nagendra Um
 
HTML5 New and Improved
Timothy Fisher
 
HTML5 and CSS3 refresher
Ivano Malavolta
 
GDG-USAR Tech winter break 2024 USAR.pdf
raiaryan174
 
About Best friends - HTML, CSS and JS
Naga Harish M
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
Syed Moosa Kaleem
 
Building a Better Web with HTML5 and CSS3
Karambir Singh Nain
 
Html5
mikusuraj
 
Html5 intro
Kevin DeRudder
 
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
 
HTML5: The Future of Web Development with IE9, IE10 and Windows 8
Shaymaa
 

More from Ramakrishna Reddy Bijjam (20)

PPTX
Regular expressions,function and glob module.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
PPTX
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
PPTX
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
DOCX
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
DOCX
Builtinfunctions in vbscript and its types.docx
Ramakrishna Reddy Bijjam
 
DOCX
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
DOCX
VBScript datatypes and control structures.docx
Ramakrishna Reddy Bijjam
 
PPTX
Numbers and global functions conversions .pptx
Ramakrishna Reddy Bijjam
 
DOCX
Filters and its types as wave shadow.docx
Ramakrishna Reddy Bijjam
 
PPTX
JavaScript Arrays and its types .pptx
Ramakrishna Reddy Bijjam
 
PPTX
JS Control Statements and Functions.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Code conversions binary to Gray vice versa.pptx
Ramakrishna Reddy Bijjam
 
PDF
FIXED and FLOATING-POINT-REPRESENTATION.pdf
Ramakrishna Reddy Bijjam
 
PPTX
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Data Frame Data structure in Python pandas.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Series data structure in Python Pandas.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Mongodatabase with Python for Students.pptx
Ramakrishna Reddy Bijjam
 
Regular expressions,function and glob module.pptx
Ramakrishna Reddy Bijjam
 
Natural Language processing using nltk.pptx
Ramakrishna Reddy Bijjam
 
Parsing HTML read and write operations and OS Module.pptx
Ramakrishna Reddy Bijjam
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
VBS control structures for if do whilw.docx
Ramakrishna Reddy Bijjam
 
Builtinfunctions in vbscript and its types.docx
Ramakrishna Reddy Bijjam
 
VBScript Functions procedures and arrays.docx
Ramakrishna Reddy Bijjam
 
VBScript datatypes and control structures.docx
Ramakrishna Reddy Bijjam
 
Numbers and global functions conversions .pptx
Ramakrishna Reddy Bijjam
 
Filters and its types as wave shadow.docx
Ramakrishna Reddy Bijjam
 
JavaScript Arrays and its types .pptx
Ramakrishna Reddy Bijjam
 
JS Control Statements and Functions.pptx
Ramakrishna Reddy Bijjam
 
Code conversions binary to Gray vice versa.pptx
Ramakrishna Reddy Bijjam
 
FIXED and FLOATING-POINT-REPRESENTATION.pdf
Ramakrishna Reddy Bijjam
 
Handling Missing Data for Data Analysis.pptx
Ramakrishna Reddy Bijjam
 
Data Frame Data structure in Python pandas.pptx
Ramakrishna Reddy Bijjam
 
Series data structure in Python Pandas.pptx
Ramakrishna Reddy Bijjam
 
Mongodatabase with Python for Students.pptx
Ramakrishna Reddy Bijjam
 
Ad

Recently uploaded (20)

PPTX
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PPTX
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
PPTX
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
PDF
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
PPTX
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
PPT
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PPTX
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
PPTX
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
PDF
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
PDF
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
Navigating English Key Stage 2 lerning needs.pptx
JaysonClosa3
 
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
How to Create & Manage Stages in Odoo 18 Helpdesk
Celine George
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
Introduction presentation of the patentbutler tool
MIPLM
 
The Gift of the Magi by O Henry-A Story of True Love, Sacrifice, and Selfless...
Beena E S
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
Lean IP - Lecture by Dr Oliver Baldus at the MIPLM 2025
MIPLM
 
Life and Career Skills Lesson 2.pptxProtective and Risk Factors of Late Adole...
ryangabrielcatalon40
 
Indian Contract Act 1872, Business Law #MBA #BBA #BCOM
priyasinghy107
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
Exploring Linear and Angular Quantities and Ergonomic Design.pptx
AngeliqueTolentinoDe
 
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
Navigating English Key Stage 2 lerning needs.pptx
JaysonClosa3
 
Ad

Structured Graphics in dhtml and active controls.docx

  • 1. Structured graphics Creating structured graphics in DHTML (Dynamic HTML) typically involves using HTML, CSS, and JavaScript to manipulate graphical elements on a webpage. While DHTML itself does not have built-in graphic capabilities like SVG or canvas, you can use a combination of HTML elements and scripting to create dynamic, structured graphics. You can use HTML elements like div, span, img, or even SVG elements to represent graphical components. For example, a div can be styled to appear as a rectangle or circle. CSS is used for styling elements to create shapes, colors, and positions that represent graphics. You can use border-radius, background-color, width, and height properties for shapes. JavaScript is used to manipulate the DOM (Document Object Model) and make the graphics interactive or animated. You can change properties dynamically, such as position, size, and color, based on user input or time intervals <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Structured Graphics in DHTML</title> <style> /* Styling the circle */ #circle { width: 100px; height: 100px; border-radius: 50%; /* Make it round */ background-color: blue; position: absolute; left: 100px;
  • 2. top: 100px; } </style> </head> <body> <div id="circle"></div> <script> // JavaScript to change the circle's position and color let circle = document.getElementById("circle"); let colors = ["blue", "green", "red", "yellow"]; let colorIndex = 0; // Change color every 1 second setInterval(() => { circle.style.backgroundColor = colors[colorIndex]; colorIndex = (colorIndex + 1) % colors.length; }, 1000); // Move the circle around every 2 seconds let x = 100; let y = 100; setInterval(() => { x += 10; y += 10; circle.style.left = x + "px"; circle.style.top = y + "px"; }, 2000);
  • 3. </script> </body> </html> If you want more complex graphics, such as shapes, lines, or animations, you might want to use the <canvas> element, which allows you to draw 2D graphics with JavaScript. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Canvas Graphics in DHTML</title> </head> <body> <canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas> <script> // Accessing the canvas element and its context let canvas = document.getElementById("myCanvas"); let ctx = canvas.getContext("2d"); // Drawing a rectangle ctx.fillStyle = "blue"; ctx.fillRect(50, 50, 150, 100); // Drawing a line
  • 4. ctx.beginPath(); ctx.moveTo(50, 50); ctx.lineTo(200, 150); ctx.strokeStyle = "red"; ctx.stroke(); </script> </body> </html> Active controls Active controls in DHTML (Dynamic HTML) refer to interactive elements on a webpage that can be manipulated using HTML, CSS, and JavaScript to create dynamic, user-driven experiences. These controls include things like buttons, input fields, dropdowns, sliders, and other elements that respond to user actions, events, or changes. In DHTML, "active" refers to the ability of these controls to respond to events like mouse clicks, keyboard input, or page load, and update the page dynamically without requiring a full page reload. JavaScript plays a critical role in enabling this interactivity, often by adding event listeners that respond to actions like click, mouseover, change, etc. Buttons Buttons are one of the simplest active controls in DHTML. They can trigger actions when clicked. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Button Example</title> <script>
  • 5. function showAlert() { alert("Button clicked!"); } </script> </head> <body> <button onclick="showAlert()">Click Me</button> </body> </html> The <button> element is used here, and the onclick event is used to trigger a JavaScript function when the button is clicked. showAlert() is a JavaScript function that displays an alert when the button is clicked. Text Input (Form Controls) Text input fields are interactive and can be used for user input. You can capture their value and take action based on that. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Text Input Example</title> <script> function displayInputValue() { let inputValue = document.getElementById("userInput").value;
  • 6. alert("You entered: " + inputValue); } </script> </head> <body> <input type="text" id="userInput" placeholder="Enter something here"> <button onclick="displayInputValue()">Submit</button> </body> </html> The <input> element allows users to enter text, and the value property is used to retrieve the text inputted by the user. The displayInputValue() function displays the input value when the button is clicked. Dropdown (Select Box) A dropdown is another active control, which lets users select an option from a list. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Dropdown Example</title> <script> function showSelectedOption() { let selectedOption = document.getElementById("fruitSelect").value;
  • 7. alert("You selected: " + selectedOption); } </script> </head> <body> <select id="fruitSelect" onchange="showSelectedOption()"> <option value="apple">Apple</option> <option value="banana">Banana</option> <option value="orange">Orange</option> </select> </body> </html> The <select> element creates a dropdown menu with options. The onchange event triggers when the user selects an option, and the value of the selected option is retrieved using JavaScript. Checkbox Checkboxes are used for binary (yes/no) selections. They can be toggled on and off. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Checkbox Example</title>
  • 8. <script> function checkStatus() { let checkbox = document.getElementById("agreeCheckbox"); if (checkbox.checked) { alert("You agreed to the terms!"); } else { alert("You did not agree to the terms."); } } </script> </head> <body> <input type="checkbox" id="agreeCheckbox"> I agree to the terms and conditions <button onclick="checkStatus()">Submit</button> </body> </html> The <input type="checkbox"> allows users to toggle between checked and unchecked states. The checked property is used in JavaScript to determine the checkbox's state. The checkStatus() function displays an alert based on whether the checkbox is checked or not. Slider (Range Input) Sliders let users select a value from a range. This is particularly useful for adjusting settings like volume or brightness. <!DOCTYPE html>
  • 9. <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Slider Example</title> <script> function updateSliderValue() { let sliderValue = document.getElementById("volumeSlider").value; document.getElementById("volumeOutput").innerText = "Volume: " + sliderValue; } </script> </head> <body> <input type="range" id="volumeSlider" min="0" max="100" value="50" oninput="updateSliderValue()"> <p id="volumeOutput">Volume: 50</p> </body> </html> The <input type="range"> creates a slider. The oninput event triggers every time the user moves the slider, and the slider's value is retrieved and displayed dynamically. Radio Buttons Radio buttons allow users to choose between multiple options, but only one option can be selected at a time. <!DOCTYPE html> <html lang="en">
  • 10. <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Active Radio Button Example</title> <script> function showSelectedRadio() { let radios = document.getElementsByName("color"); for (let radio of radios) { if (radio.checked) { alert("You selected: " + radio.value); } } } </script> </head> <body> <input type="radio" name="color" value="Red"> Red<br> <input type="radio" name="color" value="Green"> Green<br> <input type="radio" name="color" value="Blue"> Blue<br> <button onclick="showSelectedRadio()">Submit</button> </body> </html> Audio Controls:
  • 11. To embed an audio file in an HTML document, you can use the <audio> element. This element allows you to embed sound content in your page, such as music, a podcast, or any other audio file. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Audio Example</title> </head> <body> <h1>Listen to this audio</h1> <audio controls> <source src="audiofile.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> </body> </html> <audio>: This is the container element for audio. controls: This attribute adds built-in controls to the audio player, such as play, pause, volume, and seek bar. <source>: Specifies the path to the audio file and its type. In this case, it's an MP3 file (audiofile.mp3), but you can also use other formats like .ogg, .wav, etc. The text "Your browser does not support the audio element" will display if the browser doesn't support the <audio> tag.
  • 12. Radio buttons with the same name attribute form a group, allowing only one option to be selected. The showSelectedRadio() function checks which radio button is selected and displays it. Video Controls: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Video Example</title> </head> <body> <h1>Watch this video</h1> <!-- Video Element --> <video id="myVideo" width="640" height="360" controls> <source src="https://www.youtube.com/watch? v=plPnI_rVG9Q&list=RDplPnI_rVG9Q&start_radio=1" type="video/mp4"> <source src="video.ogg" type="video/ogg"> Your browser does not support the video element. </video> <!-- JavaScript to Control the Video --> <button onclick="playVideo()">Play</button> <button onclick="pauseVideo()">Pause</button>
  • 13. <button onclick="changeVolume(0.5)">Set Volume to 50%</button> <script> // Get the video element const video = document.getElementById('myVideo'); // Play video function playVideo() { video.play(); } // Pause video function pauseVideo() { video.pause(); } // Change volume function changeVolume(volume) { video.volume = volume; // volume is between 0 and 1 } </script> </body> </html> Navigator Object: The JavaScript navigator object is used for browser detection. It can be used to get browser information such as appName, appCodeName, userAgent etc. The navigator object is the window property, so it can be accessed by:
  • 14. window.navigator No. Property Description 1 appName returns the name 2 appVersion returns the version 3 appCodeName returns the code name 4 cookieEnabled returns true if cookie is enabled otherwise false 5 userAgent returns the user agent 6 language returns the language. It is supported in Netscape and Firefox only. 7 userLanguage returns the user language. It is supported in IE only. 8 plugins returns the plugins. It is supported in Netscape and Firefox only. 9 systemLanguage returns the system language. It is supported in IE only. <script> document.writeln("<br/>navigator.appCodeName: "+navigator.appCodeName); document.writeln("<br/>navigator.appName: "+navigator.appName);
  • 15. document.writeln("<br/>navigator.appVersion: "+navigator.appVersion); document.writeln("<br/>navigator.cookieEnabled: "+navigator.cookieEnabled); document.writeln("<br/>navigator.language: "+navigator.language); document.writeln("<br/>navigator.userAgent: "+navigator.userAgent); document.writeln("<br/>navigator.platform: "+navigator.platform); document.writeln("<br/>navigator.onLine: "+navigator.onLine); </script> Screen Object: <script> document.writeln("<br/>screen.width: "+screen.width); document.writeln("<br/>screen.height: "+screen.height); document.writeln("<br/>screen.availWidth: "+screen.availWidth); document.writeln("<br/>screen.availHeight: "+screen.availHeight); document.writeln("<br/>screen.colorDepth: "+screen.colorDepth); document.writeln("<br/>screen.pixelDepth: "+screen.pixelDepth); </script> HTML <meta> tag HTML <meta> tag is used to represent the metadata about the HTML document. It specifies page description, keywords, copyright, language, author of the documents, etc.
  • 16. The metadata does not display on the webpage, but it is used by search engines, browsers and other web services which scan the site or webpage to know about the webpage. With the help of meta tag, you can experiment and preview that how your webpage will render on the browser. The <meta> tag is placed within the <head> tag, and it can be used more than one times in a document. 1. <meta charset="utf-8"> It defines the character encoding. The value of charset is "utf-8" which means it will support to display any language. 2. <meta name="keywords" content="HTML, CSS, JavaScript, Tutorials"> It specifies the list of keyword which is used by search engines. 3. <meta name="description" content="Courses available in Avanthi Colleges"> It defines the website description which is useful to provide relevant search performed by search engines. 4. <meta name="author" content="thisauthor"> It specifies the author of the page. It is useful to extract author information by Content management system automatically. 5. <meta name="refresh" content="50"> It specifies to provide instruction to the browser to automatically refresh the content after every 50sec (or any given time). 6. <meta http-equiv="refresh" content="5; url=https://avanthimca.ac.in/infra"> In the above example we have set a URL with content so it will automatically redirect to the given page after the provided time.
  • 17. 7. <meta name="viewport" content="width=device-width, initial-scale=1.0"> It specifies the viewport to control the page dimension and scaling so that our website looks good on all devices. If this tag is present, it indicates that this page is mobile device supported. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="keywords" content="HTML, CSS, JavaScript, Tutorials"> <meta name="description" content="Courses available in Avanthi college"> <meta name="author" content="thisauthor"> <meta http-equiv="refresh" content="5; url=https://avanthimca.ac.in/infra"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <h2>Example of Meta tag</h2> <p>This example shows the use of meta tag within an HTML document</p> </body> </html>