HTML Articles

Page 72 of 151

Why do we use DOCTYPES in HTML document?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 2K+ Views

The DOCTYPE declaration is a document type definition that informs the web browser about the version of HTML or markup language used in a document. It serves as an instruction to the browser on how to interpret and render the HTML content correctly. Without a proper DOCTYPE, browsers may enter "quirks mode, " leading to inconsistent rendering across different browsers. Syntax Following is the syntax for the modern HTML5 DOCTYPE declaration − For older HTML versions, the DOCTYPE syntax was more complex and required DTD (Document Type Definition) references − ...

Read More

How to store a name permanently using HTML5 Local Storage?

Rishi Rathor
Rishi Rathor
Updated on 16-Mar-2026 440 Views

The Local Storage is designed for storage that spans multiple windows and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons. HTML5 localStorage saves string data in the browser and lasts beyond the current session. localStorage stores the data with no expiration, whereas sessionStorage is limited to the session only. When the browser is closed, the session is lost but localStorage data persists. The data won't get deleted when the browser is closed. Here, ...

Read More

How to limit maximum items on multiple input ()?

Jennifer Nicholas
Jennifer Nicholas
Updated on 16-Mar-2026 14K+ Views

The multiple attribute in HTML allows users to select multiple files or email addresses in input fields. However, HTML alone cannot limit the number of items selected. To restrict the maximum number of files or entries, you need to use JavaScript validation. Syntax Following is the syntax for the multiple attribute − The multiple attribute is a boolean attribute that enables selection of multiple values. It works with file and email input types. Using Multiple Attribute with File Input The multiple attribute allows users to select several files simultaneously from ...

Read More

What is the correct way of using , , or in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 8K+ Views

The HTML element creates a line break in text content. There are several correct syntaxes for using the br tag, depending on the document type you're working with. Understanding the differences helps ensure proper cross-compatibility. Syntax Following are the valid syntaxes for the br element − The element is a void element, meaning it has no content and does not require a closing tag. The space before the forward slash in ensures compatibility with older HTML parsers. HTML5 Syntax In modern ...

Read More

How to use year input type in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 25K+ Views

HTML does not have a dedicated year input type. However, you can create year input functionality using several approaches: the element with constraints, the element, or by implementing custom year picker solutions with JavaScript libraries like jQuery UI. Using Number Input Type for Year The most common approach is to use with min and max attributes to constrain the year range. The placeholder attribute helps users understand the expected format. Syntax Example Following example creates a year input field using a number input type − ...

Read More

How to store data in the browser with the HTML5 localStorage API?

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

HTML5 localStorage is a web storage API that allows you to store data directly in the user's browser. Unlike sessionStorage, which expires when the browser tab is closed, localStorage data persists indefinitely until explicitly removed by the user or the application. The localStorage API provides a simple way to store key-value pairs as strings in the browser. This feature is particularly useful for saving user preferences, form data, application state, or any data that should persist across browser sessions. Syntax Following is the syntax for storing data in localStorage − localStorage.setItem(key, value); localStorage.key = value; ...

Read More

How to redirect URL to the different website after few seconds?

George John
George John
Updated on 16-Mar-2026 7K+ Views

Page redirection is a situation where you click a URL to reach page X but are automatically directed to another page Y. This happens due to page redirection configured by the website developer. To redirect a URL to a different website after a few seconds, use the META tag with the http-equiv="refresh" attribute and the content attribute. The content attribute sets the delay in seconds before the redirect occurs. Syntax Following is the syntax for URL redirection using the META tag − Where − seconds − The number of seconds ...

Read More

How to use sockets in JavaScriptHTML?

Ankitha Reddy
Ankitha Reddy
Updated on 16-Mar-2026 285 Views

To enable bidirectional communication between web applications and server-side processes, JavaScript provides the WebSocket API. Unlike traditional HTTP requests, WebSockets maintain a persistent connection allowing real-time data exchange in both directions. WebSockets are commonly used for chat applications, live notifications, real-time gaming, stock price updates, and collaborative editing tools where instant communication is essential. Syntax Following is the syntax to create a WebSocket connection − const socket = new WebSocket(url [, protocols]); Where url is the WebSocket server URL (starting with ws:// or wss://) and protocols is an optional string or array of ...

Read More

Create a shortcut key to activate an element in HTML

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 3K+ Views

The accesskey attribute in HTML allows you to create keyboard shortcuts for activating elements like links, buttons, and form controls. This global attribute enhances web accessibility and provides quick navigation options for users. The accesskey attribute accepts a single character value that, when combined with browser-specific modifier keys, activates the associated element. This feature is particularly useful for improving website usability and accessibility. Syntax Following is the syntax for the accesskey attribute − Content The character value must be a single printable character that can be typed on a keyboard, including letters, numbers, ...

Read More

How to add an address element in HTML?

Yaswanth Varma
Yaswanth Varma
Updated on 16-Mar-2026 1K+ Views

The address element in HTML represents contact information for a person, organization, or article. It provides semantic meaning to contact details and helps search engines and assistive technologies understand the purpose of the content. When used within the element, it represents contact information for the entire document. When placed inside an element, it represents contact information specific to that article. The element accepts all global attributes and is typically displayed in italics by default in most browsers. Syntax Following is the syntax for the address element − Contact ...

Read More
Showing 711–720 of 1,509 articles
« Prev 1 70 71 72 73 74 151 Next »
Advertisements