In HTML, the div element is one of the most versatile block-level containers used to structure and organize web content. The tag creates logical divisions on web pages for text, images, headers, footers, navigation bars, and other elements. It requires both opening and closing tags, making it essential for proper HTML structure. Using divs effectively helps grab users' attention while maintaining proper layout boundaries and preventing content overflow beyond the browser window. This article explores techniques to create engaging div-based layouts that remain contained within the viewport. Understanding Overflow in Div Elements The overflow ... Read More
When creating HTML content, you may need to preserve multiple spaces, tabs, and line breaks exactly as they appear in your source code. By default, HTML collapses multiple whitespace characters into a single space and ignores line breaks. The and tags will not display extra spaces or line breaks as written in your HTML file. This article demonstrates two effective methods to render HTML strings while preserving all original spacing and line breaks. Method Overview Using the HTML Tag Using the CSS white-space Property Using the HTML Tag The ... Read More
The oncontextmenu event attribute in HTML is triggered when a user right-clicks on an element to open the context menu. This event allows developers to customize behavior when the context menu appears, such as displaying custom menus or preventing the default context menu from showing. Syntax Following is the syntax for the oncontextmenu event attribute − Content The script can be a JavaScript function call or inline JavaScript code that executes when the user right-clicks on the element. Parameters The oncontextmenu event handler receives an event object as a parameter with the ... Read More
The HTML DOM Video duration property returns the duration of a video in seconds as a numeric value. This read-only property is essential for creating custom video controls, progress bars, and displaying video information to users. Note − For live streams, the duration property returns Infinity because live content has no predefined end time. Syntax Following is the syntax for accessing the duration property − videoObject.duration Return Value The duration property returns a numeric value representing − The length of the video in seconds (for recorded videos) Infinity for live ... Read More
Forms are a crucial component of any web application, containing input fields for information like names, emails, and dates. A datepicker is an interactive dropdown calendar that allows users to select dates easily without manually typing them. This feature is commonly used for birthdate entries, appointment scheduling, and event planning. In HTML5, adding a datepicker to forms is straightforward using the built-in element, which provides native browser support for date selection. HTML The element with type="date" creates input fields where users can enter dates using either a text box with validation or a visual ... Read More
The Location search property returns or sets the query string portion of a URL, including the leading question mark (?). This property allows you to read the search parameters from the current URL or programmatically modify them. Syntax Following is the syntax for getting the search property − location.search Following is the syntax for setting the search property − location.search = searchString Parameters searchString − A string representing the query parameters, including the leading question mark. For example: "?name=john&age=25" Return Value Returns a string containing the query ... Read More
The HTML DOM Input Range type property is associated with input elements having type="range". This property returns the string "range" for range input elements, confirming their input type programmatically. The range input type creates a slider control that allows users to select a numeric value within a specified range. The type property helps identify and validate that an input element is indeed a range slider. Syntax Following is the syntax for accessing the type property of a range input element − rangeObject.type Return Value The type property returns a string value "range" ... Read More
The ondrag event attribute in HTML is triggered continuously while an element is being dragged. This event fires repeatedly during the drag operation, making it useful for providing real-time feedback or updating the interface while dragging is in progress. By default, HTML images and links are draggable without requiring the draggable="true" attribute. For other elements like , , or , you must explicitly set draggable="true" to make them draggable. Syntax Following is the syntax for the ondrag event attribute − Content Parameters script − JavaScript code to execute when the element ... Read More
Markup languages are computer languages that use symbols or tags to structure, format, and describe relationships between portions of text documents. Unlike traditional programming languages with strict syntax, markup languages are designed to be more human-readable and easier to understand. While HTML is the most widely known markup language for web development, several other markup languages serve different purposes and offer unique capabilities. XML (Extensible Markup Language) XML is a markup language designed to store and transport structured data using custom-defined tags. Unlike HTML, which has predefined tags for presentation, XML allows developers to create their own tags ... Read More
The HTML DOM Input Range value property is associated with input elements having type="range". It returns or sets the current value of the range slider control. The value can be the default value specified in HTML or a value set by the user dragging the slider. Syntax Following is the syntax for getting the value property − var value = rangeObject.value; Following is the syntax for setting the value property − rangeObject.value = number; Here, number is a numeric value within the range defined by the min and max attributes ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance