Priya Pallavi

Priya Pallavi

45 Articles Published

Articles by Priya Pallavi

45 articles

How to display human readable date in HTML?

Priya Pallavi
Priya Pallavi
Updated on 16-Mar-2026 619 Views

Use the HTML tag to display human-readable dates and times while providing machine-readable datetime information for browsers, search engines, and assistive technologies. The element enhances accessibility and helps with SEO by making temporal content semantically meaningful. Syntax Following is the syntax for the HTML tag − Human readable date/time The datetime attribute is optional but recommended for providing precise machine-readable temporal information. Attributes The tag supports the following specific attribute − Attribute Value Description datetime Valid datetime string Specifies the ...

Read More

How to set the top padding of an element with JavaScript?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 674 Views

Use the paddingTop property in JavaScript to set the top padding of an element. This property allows you to dynamically modify the spacing between an element's content and its top border. Syntax element.style.paddingTop = "value"; Where value can be specified in pixels (px), percentages (%), or other CSS units. Example #box { border: 2px solid #FF0000; ...

Read More

How to return the "time" portion of the Date as a string using the current locale's conventions?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 153 Views

To return the "time" portion of the Date as a string, using the current locale's conventions, use the toLocaleTimeString() method. The toLocaleTimeString() method relies on the underlying operating system in formatting dates. It converts the date to a string using the formatting convention of the operating system where the script is running. For example, in the United States, the time appears in 12-hour format with AM/PM, whereas in many European countries, it appears in 24-hour format. Syntax date.toLocaleTimeString([locales], [options]) Parameters locales (optional): A string or array of strings representing locale identifiers (e.g., ...

Read More

Is it safe to assume strict comparison in a JavaScript switch statement?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 202 Views

JavaScript switch statements use strict comparison (===) to match cases, not loose comparison (==). This means both value and type must match exactly. Understanding Switch Comparison Let's test this with a simple example to see which case matches: switch(1) { case '1': alert('Switch comparison: Not Strict.'); break; case 1: alert('Switch comparison: Strict.'); break; default: alert('Default'); } ...

Read More

Set how much the item will grow relative to the rest of JavaScript.

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 126 Views

Use the flexGrow property to set how much the item will grow relative to the rest of the flexible items with JavaScript. Syntax element.style.flexGrow = "value"; Parameters The flexGrow property accepts a numeric value that defines the growth factor: 0 - Item won't grow (default) 1 - Item grows equally with other flex items 2 or higher - Item grows proportionally more than others Example You can try to run the following code to learn how to work with flexGrow ...

Read More

What are the document methods supported by Legacy DOM?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 166 Views

The Legacy DOM provided several document methods for manipulating document content. While most are deprecated in modern web development, understanding them helps with legacy code maintenance. Legacy DOM Document Methods Method Description & Usage clear() Deprecated - Erased document contents and returned nothing. Example: document.clear() close() Closes a document stream opened with open() method. Example: document.close() open() Deletes existing content and opens a stream for new content. Example: document.open() write() Inserts strings into the document during parsing or after open(). Example: document.write("Hello World") ...

Read More

What is onkeydown event in JavaScript?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 435 Views

The onkeydown event in JavaScript triggers when a user presses down a key on the keyboard. This event occurs before the key is released and before the character appears in the input field, making it useful for intercepting keystrokes and implementing custom keyboard behaviors. Syntax element.onkeydown = function(event) { // Handle keydown event }; // Or using addEventListener element.addEventListener('keydown', function(event) { // Handle keydown event }); Basic Example Onkeydown Example ...

Read More

Shorthand property to set the font with CSS

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 263 Views

The CSS font property is a shorthand that allows you to set multiple font-related properties in a single declaration, including font style, variant, weight, size, line-height, and family. Syntax font: [font-style] [font-variant] [font-weight] font-size[/line-height] font-family; The font-size and font-family values are required, while other properties are optional. Example Here's how to use the font shorthand property to apply multiple font styles at once: .shorthand-example ...

Read More

Add or subtract space between the words of a sentence with CSS

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 455 Views

The word-spacing property is used to add or subtract space between the words of a sentence. Possible values are normal or a number specifying space. Syntax word-spacing: normal | length | initial | inherit; Parameters Value Description normal Default spacing between words length ...

Read More

What is arguments object in JavaScript?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 278 Views

The arguments object in JavaScript is an array-like object that contains all the arguments passed to a function. It allows functions to accept a variable number of parameters and access them dynamically. Syntax arguments[index] arguments.length Properties The arguments object has two main properties: length - Returns the number of arguments passed to the function index - Access individual arguments using bracket notation (0-based) Basic Example ...

Read More
Showing 1–10 of 45 articles
« Prev 1 2 3 4 5 Next »
Advertisements