The HTML DOM Samp Object represents the HTML element, which is used to display sample output from computer programs, scripts, or systems. The element typically renders text in a monospace font to distinguish it from regular content. The DOM Samp Object provides access to all standard HTML element properties and methods, allowing you to manipulate elements dynamically with JavaScript. Syntax To create a new Samp object using JavaScript − document.createElement("SAMP"); To access an existing element − document.getElementById("sampId"); document.getElementsByTagName("samp")[0]; Creating a Samp Object You can ... Read More
When building forms in HTML, text inputs and select dropdowns often appear to have different widths even when the same width is applied in CSS. This happens because browsers handle the box model differently for different form elements, with padding and borders affecting the total rendered size. The solution is to use the CSS box-sizing property set to border-box. This ensures that padding and borders are included within the specified width rather than added to it, making all form elements render at exactly the same visual width. Syntax Following is the syntax for the box-sizing property − ... Read More
The tag is used to create a drop-down list in HTML. A selectable list allows users to choose one or more options from a predefined set of values. By adding the multiple attribute to the element, users can select multiple options by holding the Ctrl key (Windows) or Cmd key (Mac) while clicking. Syntax Following is the basic syntax for creating a selectable list − Option Text 1 Option Text 2 To create a multiple selection list, add the multiple attribute − ... Read More
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
The HTML DOM Parameter Object represents the element in an HTML document. The element defines parameters for elements, typically used for embedding multimedia content like audio, video, or plugins. Syntax Following is the syntax to create a param object using JavaScript − document.createElement("PARAM"); Following is the HTML syntax for the element − Properties of Parameter Object The Parameter Object has two main properties that correspond to its HTML attributes − Property Description ... Read More
The HTML DOM Option defaultSelected property returns a boolean value indicating whether an option element was selected by default when the page loaded. This property reflects the presence of the selected attribute in the HTML markup, not the current selection state. Syntax Following is the syntax for the defaultSelected property − optionObject.defaultSelected Return Value The defaultSelected property returns − true if the option was selected by default (has the selected attribute) false if the option was not selected by default Basic Example Following example demonstrates the defaultSelected property ... Read More
The pull-down-to-refresh feature in Chrome for Android automatically refreshes the page when users pull down from the top. While this enhances user experience in most cases, it can interfere with web applications that have their own scrolling interactions or custom refresh mechanisms. The Problem When users interact with custom scrollable content, chat interfaces, or touch-based applications, the browser's pull-to-refresh can trigger unintentionally. This creates a poor user experience where the entire page refreshes when users only intended to scroll within a specific area. Syntax Following is the CSS syntax to disable the pull-down-to-refresh feature − ... Read More
The DOM option label property is used to get or set the value of the label attribute of an element in HTML. The label attribute provides a shorter alternative text for the option, which can be displayed in the dropdown instead of the option's content. Syntax Following is the syntax to return the label value − object.label Following is the syntax to modify the label value − object.label = "text" Return Value The property returns a string representing the value of the label attribute. If no label attribute ... Read More
Images in HTML are draggable and selectable by default, which allows users to drag them to other locations or select them by double-clicking. You can prevent this behavior using CSS properties without requiring JavaScript. CSS Properties for Preventing Image Interaction The following CSS properties control image dragging and selection − user-drag − Controls whether an element can be dragged by the user. user-select − Controls whether the text of an element can be selected. -webkit-user-drag − WebKit-based browsers (Chrome, Safari) specific property for drag control. -webkit-user-select − WebKit-based browsers specific property for selection control. -moz-user-select − ... Read More
The HTML DOM option value property allows you to get or set the value of an element within a dropdown. This value is what gets sent to the server when the form is submitted, which may differ from the visible text displayed to the user. Syntax Following is the syntax for returning the value − optionObject.value Following is the syntax for setting the value − optionObject.value = "newValue" Parameters newValue − A string that specifies the new value for the option element. Return Value ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Economics & Finance