Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
HTML Articles
Page 78 of 151
How do we add a single-line input field in HTML?
To add a single-line input field in HTML, use the tag with type="text". This creates a text input field where users can enter data. The tag is a self-closing element and one of the most versatile form elements in HTML. Note: The article mentioned tag, but this tag has been deprecated since HTML 4.01 and removed entirely in HTML5. Modern web development uses the tag instead. Syntax Following is the basic syntax for creating a single-line input field − For better accessibility and user experience, it's recommended to ...
Read MoreExecute a script when a mouse pointer moves out of an element in HTML?
The onmouseout attribute in HTML triggers when the mouse pointer moves away from an element. This event is commonly used for interactive effects like changing colors, hiding tooltips, or resetting element states when the user moves their cursor away. Syntax Following is the syntax for the onmouseout attribute − Content The script can be a JavaScript function call or inline JavaScript code that executes when the mouse pointer leaves the element. Basic Example Following example demonstrates the onmouseout event changing text color when the mouse leaves the heading − ...
Read MoreExecute a script when a user navigates away from a page in HTML?
When a user navigates away from a page, you can execute JavaScript code using the onpagehide event attribute. This event triggers when the user leaves the page by clicking a link, closing the browser tab, submitting a form, refreshing the page, or navigating to another URL. The onpagehide event is part of the HTML5 Page Visibility API and provides a reliable way to detect when users are leaving your page, making it useful for cleanup tasks, saving user data, or logging analytics. Syntax Following are the different ways to use the onpagehide event − HTML attribute ...
Read MoreExecute a script each time the volume of a video/audio is changed in HTML?
The onvolumechange attribute fires when the user changes the volume of a video or audio element. This event triggers for any volume modification including volume up, volume down, mute, or unmute operations. Syntax Following is the syntax for using the onvolumechange attribute − ... ... The function is called whenever the volume property of the media element changes, including programmatic changes and user interactions with the volume controls. Using onvolumechange with Video Element Example Following example demonstrates the onvolumechange attribute with a video element − ...
Read MoreHow to display human readable date in HTML?
Use the HTML tag to display human-readable dates and times while providing machine-readable datetime information for browsers, search engines, and assistive technologies. The element enhances accessibility and helps with SEO by making temporal content semantically meaningful. Syntax Following is the syntax for the HTML tag − Human readable date/time The datetime attribute is optional but recommended for providing precise machine-readable temporal information. Attributes The tag supports the following specific attribute − Attribute Value Description datetime Valid datetime string Specifies the ...
Read MoreExecute a script when a mouse pointer moves over an element in HTML?
The onmouseover attribute in HTML triggers when a mouse pointer moves over an element. This event is commonly used to create interactive effects such as changing colors, displaying tooltips, or showing additional content when users hover over elements. Syntax Following is the syntax for the onmouseover attribute − Content The script parameter contains JavaScript code that executes when the mouse pointer enters the element's area. Basic Onmouseover Example Following example demonstrates how to change text color when hovering over a heading − Onmouseover Example ...
Read MoreExecute a script when the media is paused either by the user or programmatically in HTML?
The onpause attribute in HTML is an event handler that triggers when a media element (audio or video) is paused, either by user interaction or programmatically through JavaScript. This attribute allows you to execute custom JavaScript functions when the media playback is paused. Syntax Following is the syntax for the onpause attribute − Following is the syntax for programmatic usage − element.onpause = function() { /* code */ }; Using onpause with Video Element The onpause attribute is commonly used with and ...
Read MoreExecute a script when an element's scrollbar is being scrolled in HTML?
When an element's scrollbar is being scrolled, the onscroll event attribute triggers and executes a specified JavaScript function. This event fires when the user scrolls within an element that has scrollable content, making it useful for creating interactive scroll-based behaviors. Syntax Following is the syntax for the onscroll event attribute − Content Alternatively, you can add the scroll event listener using JavaScript − element.addEventListener('scroll', functionName); How It Works The onscroll event fires whenever the scrollTop or scrollLeft property of an element changes due to user interaction. This includes scrolling ...
Read MoreExecute a script when a reset button in a form is clicked in HTML?
The onreset attribute in HTML is an event handler that executes a JavaScript function when a form's reset button is clicked. This attribute is applied to the element and triggers before the form fields are actually reset to their default values. Syntax Following is the syntax for using the onreset attribute − The onreset attribute calls the specified JavaScript function when the user clicks the reset button or programmatically resets the form. Basic Example Following example demonstrates how to execute a ...
Read MoreExecute a script when the browser window is being resized in HTML?
The onresize attribute in HTML executes a JavaScript function when the browser window is resized. This event is commonly used to adjust layouts, recalculate dimensions, or trigger responsive behavior when users change their window size. Syntax Following is the syntax for the onresize attribute − Content The onresize attribute is typically used on the element or object to detect when the entire browser window is resized. Using onresize with Alert Following example shows how to trigger an alert when the browser window is resized − ...
Read More