HTML Articles

Page 83 of 151

Execute a script when the element loses focus in HTML?

Govinda Sai
Govinda Sai
Updated on 16-Mar-2026 342 Views

The onblur attribute in HTML is used to execute a JavaScript function when an element loses focus. This event is triggered when a user clicks outside the element, tabs to another element, or navigates away from the current input field. Syntax Following is the syntax for the onblur attribute − The function() can be a JavaScript function name or inline JavaScript code that executes when the element loses focus. Text Input with onblur The most common use case is with form input fields where you want to validate or format data ...

Read More

How to specify the number of visible options for in HTML?

varma
varma
Updated on 16-Mar-2026 146 Views

The size attribute in HTML is used to specify the number of visible options in a dropdown list. By default, a select element shows only one option and displays as a dropdown. When you add the size attribute, it transforms the dropdown into a scrollable list box showing multiple options at once. Syntax Following is the syntax for the size attribute − Option 1 Option 2 Where number is a positive integer representing how many options should be visible without scrolling. Default Behavior vs ...

Read More

How do we add the width in characters for in HTML?

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

The size attribute in HTML input elements specifies the visible width of an input field in terms of characters. This attribute controls how wide the input field appears on the screen, making it useful for creating forms with appropriately sized input fields based on expected content length. The size attribute works with text-based input types including text, search, tel, url, email, and password. While it affects the display width, it does not limit the actual number of characters a user can enter − that requires the maxlength attribute. Syntax Following is the syntax for the size attribute ...

Read More

Set the width of the element in HTML

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

The width attribute in HTML sets the width of an element in pixels. This attribute is supported by several HTML elements including , , , , , and . The width attribute provides a quick way to control element dimensions directly in HTML markup. Syntax Following is the syntax for using the width attribute − The value is specified in pixels as a positive integer. For example, width="300" sets the element width to 300 pixels. Elements Supporting Width Attribute The width attribute can be used with the following HTML elements − ...

Read More

Set the size of the icons in HTML

Nikhilesh Aleti
Nikhilesh Aleti
Updated on 16-Mar-2026 7K+ Views

In this article, we are going to discuss how to set the size of the icons in HTML. Icons are essential visual elements that enhance user experience by providing intuitive symbols for actions, navigation, and content representation. An icon is a symbol that represents a specific action on a webpage. The Icon Fonts contain symbols and glyphs that can be easily styled with CSS just like regular text. There are several icon libraries (fonts) that provide icons and can be used on HTML webpages. The prominent icon fonts frequently used by web developers are Font Awesome, Bootstrap Glyphicons, ...

Read More

Set the number of columns to span in HTML

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

The colspan attribute in HTML allows you to set the number of columns that a table cell should span. This enables a single or element to stretch across multiple columns, similar to the "merge cells" feature in spreadsheet applications like Excel. The colspan attribute is essential for creating complex table layouts where certain cells need to occupy more horizontal space than others, such as headers that span across multiple data columns or summary rows that extend across the entire table width. Syntax Following is the syntax for the colspan attribute − Content Content ...

Read More

How to set the URL of the media file in HTML?

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

In this article, we are going to learn about how to set the URL of the media file in HTML using the element. This element allows you to specify multiple media sources with different formats, enabling browsers to choose the most suitable format they support. The element is used inside , , and elements to provide alternative media resources. By offering multiple formats, you ensure better cross-browser compatibility and optimal media delivery across different devices and platforms. Syntax Following is the syntax for the element − The src ...

Read More

Execute a script when the user pastes some content in an element in HTML?

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

In this article, we are going to execute a script when the user pastes content into an element in HTML. The onpaste event is triggered when a user pastes content into an element, making it useful for validation, formatting, or tracking paste operations. Although all HTML elements accept the onpaste event, you cannot actually paste content into elements like or unless they have the contenteditable attribute set to "true". Most commonly, the onpaste event is used with elements of type="text" and elements. Syntax Following is the syntax for using the onpaste event in ...

Read More

Set the language of the track text data in HTML

Abhinanda Shri
Abhinanda Shri
Updated on 16-Mar-2026 198 Views

The srclang attribute in HTML5 is used to specify the language of the track text data. This attribute is essential when working with elements to provide subtitles, captions, descriptions, or other text tracks for multimedia content. The srclang attribute helps browsers and assistive technologies understand what language the track content is written in. Syntax Following is the syntax for the srclang attribute − The language-code should be a valid BCP 47 language tag, such as "en" for English, "es" for Spanish, or "fr" for French. Parameters The srclang attribute accepts ...

Read More

How to specify the URL of the image to use in different situations in HTML?

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

Use the srcset attribute to specify the URL of the image to use in different situations in HTML. This attribute allows you to provide multiple image sources for responsive images, enabling browsers to choose the most appropriate image based on screen size, resolution, or other conditions. Syntax The srcset attribute can be used in two main ways − Using srcset with img Element The srcset attribute on the element allows you to specify multiple image sources with their respective widths or pixel densities. The browser automatically selects ...

Read More
Showing 821–830 of 1,509 articles
« Prev 1 81 82 83 84 85 151 Next »
Advertisements