Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Priya Pallavi
45 articles
How to display human readable date in HTML?
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 MoreHow to set the top padding of an element with JavaScript?
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 MoreHow to return the "time" portion of the Date as a string using the current locale's conventions?
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 MoreIs it safe to assume strict comparison in a JavaScript switch statement?
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 MoreSet how much the item will grow relative to the rest of JavaScript.
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 MoreWhat are the document methods supported by Legacy DOM?
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 MoreWhat is onkeydown event in JavaScript?
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 MoreShorthand property to set the font with CSS
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 MoreAdd or subtract space between the words of a sentence with CSS
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 MoreWhat is arguments object in JavaScript?
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