HTML Articles

Page 81 of 151

How do we add the maximum number of characters allowed in an element in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 396 Views

In HTML, the maxlength attribute is used to limit the maximum number of characters that can be entered in an input field or textarea element. This attribute helps control user input and ensures data consistency in forms by preventing users from entering more characters than allowed. Syntax Following is the syntax for the maxlength attribute − Following is the syntax for textarea elements − Here, number represents the maximum number of characters allowed. The value must be a non-negative integer. Basic Usage with Input Fields The ...

Read More

Execute a script when the dragged element is being dropped in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 375 Views

The ondrop event in HTML is triggered when a dragged element or text selection is dropped onto a valid drop target. This event is essential for implementing drag and drop functionality, allowing users to move elements between different areas of a webpage. The ondrop event works in conjunction with other drag events like ondragstart, ondragover, and ondrag to create a complete drag and drop experience. Syntax Following is the syntax for the ondrop event − content The ondrop event handler receives an event object that contains information about the drag operation, including the ...

Read More

Execute a script when the length of the media changes in HTML?

Nikitha N
Nikitha N
Updated on 16-Mar-2026 287 Views

The ondurationchange attribute in HTML triggers when the duration of an audio or video element changes. This event occurs when the browser has loaded enough of the media file to determine its total length, or when the duration metadata becomes available. Syntax Following is the syntax for the ondurationchange attribute − The attribute can also be added using JavaScript − audioElement.ondurationchange = function() { /* code */ }; videoElement.addEventListener("durationchange", myFunction); When Duration Changes Occur The ondurationchange event is fired in the following scenarios − When ...

Read More

How to specify a minimum value in HTML?

Sravani S
Sravani S
Updated on 16-Mar-2026 196 Views

The min attribute in HTML is used to specify the minimum allowed value for input elements. This attribute is primarily used with input types like number, range, date, datetime-local, month, time, and week to enforce validation constraints on user input. Syntax Following is the syntax for using the min attribute − Where value represents the minimum acceptable value based on the input type. For numeric inputs, it's a number; for date inputs, it's a date string in the appropriate format. Using Min with Number Input The most common use of the ...

Read More

How to specify the HTTP method to use when sending form-data in HTML?

Smita Kapse
Smita Kapse
Updated on 16-Mar-2026 311 Views

The method attribute in HTML forms specifies the HTTP method to use when sending form data to the server. This attribute determines how the browser packages and transmits the form data when the user submits the form. Syntax Following is the syntax for the method attribute − The value can be either get or post, with get being the default if not specified. HTTP Methods HTML forms support two primary HTTP methods − GET Method The GET method appends form data to the URL as ...

Read More

How to specify that a user can enter more than one value in HTML?

Nishtha Thakur
Nishtha Thakur
Updated on 16-Mar-2026 207 Views

The multiple attribute in HTML allows users to select or enter more than one value in specific form elements. This attribute is commonly used with elements of type file and email, as well as with elements to enable multi-selection capabilities. Syntax Following is the syntax for using the multiple attribute − ... The multiple attribute is a boolean attribute, which means its presence alone enables the functionality. You can write it as multiple, multiple="", or multiple="multiple". Multiple File Selection The most common use of the multiple attribute is ...

Read More

Execute a script when an error occurs in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 286 Views

The onerror event in HTML allows you to execute a script when an error occurs while loading external resources like images, scripts, or stylesheets. This event is essential for handling loading failures gracefully and providing user feedback when resources cannot be accessed. The onerror event is triggered when an external file fails to load, such as when an image source is broken, a script file is missing, or a stylesheet cannot be found. This event helps improve user experience by allowing developers to display alternative content or error messages. Syntax Following is the syntax for using the ...

Read More

How to specify that the details should be visible to the user in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 295 Views

The element in HTML creates interactive widgets that users can open and close to reveal additional content. By default, the details are hidden and only the summary text is visible. You can control whether the details should be initially visible using the open attribute. Syntax Following is the syntax for the element − Summary text Content to be revealed... To make the details visible by default, use the open attribute − Summary text Content that ...

Read More

How do we set what value is the optimal value for the gauge in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 263 Views

The optimum attribute in HTML's element defines the optimal or ideal value for a gauge. This attribute helps browsers determine the best visual representation of the meter by indicating what range of values should be considered "good" or preferred. The element, also known as a gauge, displays scalar measurements within a defined range. The optimum attribute works alongside other attributes like low and high to create visual zones that indicate whether the current value is in a good, average, or poor range. Syntax Following is the syntax for the optimum attribute in the meter element ...

Read More

How to display a short hint that describes the expected value of the element in HTML?

Daniol Thomas
Daniol Thomas
Updated on 16-Mar-2026 361 Views

The placeholder attribute in HTML displays a short hint that describes the expected value of an input element. This hint appears inside the input field when it is empty and disappears when the user starts typing. It provides users with guidance on what type of information to enter without taking up additional screen space. Syntax Following is the syntax for the placeholder attribute − The placeholder text should be concise and descriptive, helping users understand the expected input format or content. Supported Elements The placeholder attribute works with the following HTML ...

Read More
Showing 801–810 of 1,509 articles
« Prev 1 79 80 81 82 83 151 Next »
Advertisements