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
Front End Technology Articles
Page 81 of 652
How to add the value of the element in HTML?
The value attribute in HTML specifies the initial or default value for various form elements. It serves different purposes depending on the element type − from setting default text in input fields to defining the data sent when buttons are clicked. Understanding how to properly use the value attribute is essential for creating functional HTML forms. Syntax Following is the basic syntax for using the value attribute − The value attribute can be used with the following HTML elements − − Sets default value for form inputs − Defines ...
Read MoreExecute a script after the document is printed in HTML?
The onafterprint event attribute in HTML executes a JavaScript function after the user has printed the document or closed the print preview dialog. This event is useful for tracking print actions, cleaning up resources, or providing user feedback after printing. Syntax Following is the syntax for the onafterprint attribute − You can also use it with JavaScript event listeners − window.addEventListener("afterprint", functionName); Using onafterprint Attribute The onafterprint attribute is typically added to the element and triggers when the print dialog is closed, regardless of whether the user ...
Read MoreExecute a script when a context menu is triggered in HTML5?
The contextmenu attribute in HTML5 allows you to execute a script when a context menu is triggered. A context menu appears when a user right-clicks on an element. This attribute links an element to a custom element that defines the context menu options. Syntax Following is the syntax for the contextmenu attribute − Content The contextmenu attribute value must match the id of a element with type="context". Basic Context Menu Example Following example demonstrates how to create a basic context ...
Read MoreExecute a script when the element is being clicked in HTML?
Use the onclick attribute to execute a script when an element is clicked in HTML. The onclick attribute allows you to run JavaScript functions directly when a user interacts with elements like buttons, links, divs, or any clickable HTML element. Syntax Following is the syntax for the onclick attribute − Content You can also execute JavaScript code directly within the onclick attribute − Content Using onclick with Button Elements Example − Basic onclick Function Following example demonstrates how to use the onclick attribute to execute a JavaScript function ...
Read MoreHow to specify the URL of the page the link goes to in HTML?
The href attribute in HTML is used to specify the URL of the page that a link should navigate to. The href attribute is primarily used with the (anchor) tag to create hyperlinks that allow users to navigate between web pages or different sections within the same page. Syntax Following is the syntax for using the href attribute with anchor tags − Link Text The URL can be an absolute URL, relative URL, or an anchor link to a section within the same page. Types of URLs in href Attribute The ...
Read MoreExecute a script each time the playback rate changes in HTML?
The onratechange event attribute in HTML executes a JavaScript function whenever the playback rate of an audio or video element changes. This event is particularly useful for creating custom media controls or displaying the current playback speed to users. Syntax Following is the syntax for the onratechange attribute − ... ... The onratechange attribute can be used with both and elements. The function specified will execute each time the playbackRate property changes. Playback Rate Property The playbackRate property controls the speed at which media content plays − 1.0 ...
Read MoreSet the language of the linked document in HTML
The hreflang attribute in HTML specifies the language of the linked document. This attribute helps search engines understand the language of the target page and assists browsers in providing appropriate language-based features to users. Syntax Following is the syntax for the hreflang attribute − Link Text The language-code follows the ISO 639-1 standard (two-letter language codes) and can optionally include a country code using ISO 3166-1 alpha-2 format. Common Language Codes Here are some commonly used language codes with the hreflang attribute − Language Code Language Example Usage ...
Read MoreGet the HTTP header for the information of the content attribute in HTML
The http-equiv attribute in HTML is used within tags to simulate HTTP response headers. It provides metadata that would normally be sent by a web server, allowing you to control browser behavior and document properties directly from the HTML. The http-equiv attribute works in conjunction with the content attribute to specify both the header name and its value. This is particularly useful for setting refresh intervals, character encoding, cache control, and other HTTP-like directives. Syntax Following is the syntax for the http-equiv attribute − Where header-name is the HTTP header to ...
Read MoreExecute a script when the element gets focus in HTML?
The onfocus attribute in HTML executes a JavaScript function when an element receives focus. Focus occurs when a user clicks on an input field, tabs to it using the keyboard, or programmatically selects it. This attribute is commonly used with form elements like input fields, text areas, and select dropdowns. Syntax Following is the syntax for the onfocus attribute − The onfocus attribute accepts a JavaScript function call or inline JavaScript code that executes when the element gains focus. Example − Input Field Focus Following example demonstrates how to change the ...
Read MoreHow to copy the content of one HTML5 Canvas to another Canvas locally?
The drawImage() method in HTML5 Canvas allows you to copy content from one canvas to another canvas locally within the same web page. This method can draw images, canvases, and videos onto a canvas element, making it perfect for duplicating or transferring canvas content. Syntax Following is the basic syntax for copying canvas content using drawImage() − destinationContext.drawImage(sourceCanvas, dx, dy); Where sourceCanvas is the source canvas element, and dx, dy are the destination coordinates on the target canvas. How Canvas Copying Works To copy canvas content, you need to obtain the 2D ...
Read More