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 Nishtha Thakur
Page 4 of 40
How to get a number of days in a specified month using JavaScript?
To get the number of days in a specified month in JavaScript, you can use the Date constructor with a clever trick: create a date for the first day of the next month, then subtract one day to get the last day of the target month. The Date Constructor Trick The key insight is that new Date(year, month, 0) returns the last day of the previous month. Since JavaScript months are zero-indexed (0 = January, 1 = February, etc.), passing the actual month number gives us the last day of that month. Basic Implementation ...
Read MoreHow to use window.location to redirect to a different URL with JavaScript?
You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. This happens due to page redirection. JavaScript provides several methods to redirect users to different URLs using the window.location object. This is useful for creating dynamic navigation, handling authentication, or redirecting after form submissions. Common Redirect Methods There are three main ways to redirect using window.location: Method Description Back Button Behavior ...
Read MoreHow to call multiple JavaScript functions in onclick event?
To call multiple JavaScript functions in onclick event, you can separate them with semicolons. This allows you to execute several functions sequentially when a single click occurs. Syntax onclick="function1(); function2(); function3()" Method 1: Using Semicolons The simplest approach is to separate multiple function calls with semicolons directly in the onclick attribute: function Display1() { document.getElementById("output").innerHTML += "Hello there!"; } ...
Read MoreDifference between PX, EM and Percent
In CSS, units of measurement define how sizes and distances are calculated. The three most commonly used units are px (pixels), em (relative to font size), and % (percentage). Each has different behaviors and use cases. Syntax selector { property: value px; /* Absolute pixel units */ property: value em; /* Relative to font size */ property: value%; /* Percentage of parent element */ } Unit Comparison UnitTypeRelative ToBest For ...
Read MoreCSS rest-after Speech Media property
The CSS rest-after property is used in speech media to specify a pause or rest period after an element is spoken. This property is particularly useful for screen readers and text-to-speech applications to create natural-sounding speech patterns. Syntax selector { rest-after: time | none | x-weak | weak | medium | strong | x-strong; } Possible Values ValueDescription Sets pause duration in seconds (s) or milliseconds (ms) noneNo pause after the element x-weakExtra weak pause (shortest) weakWeak pause mediumMedium pause (default) strongStrong pause x-strongExtra strong pause (longest) ...
Read MoreAnimate CSS text-decoration-color property
The CSS text-decoration-color property controls the color of text decorations like underlines, overlines, and line-throughs. You can animate this property to create smooth color transitions in text decorations. Syntax selector { text-decoration-color: color; animation: animation-name duration timing-function; } Example: Animating Text Decoration Color The following example demonstrates how to animate the text-decoration-color property from the default color to orange − .animated-text { font-size: 24px; ...
Read MoreUse CSS max-width property responsive for video player
The CSS max-width property can be used to make video players responsive by preventing them from exceeding their container's width while maintaining their aspect ratio. This ensures videos adapt smoothly to different screen sizes. Syntax video { max-width: value; height: auto; } Example The following example demonstrates how to create a responsive video player using the max-width property − .video-container { ...
Read MoreHow to position text to bottom right on an image with CSS
To position text at the bottom right of an image, use CSS positioning properties. The parent container needs position: relative while the text element uses position: absolute with bottom and right properties to achieve precise placement. Syntax .container { position: relative; } .text-overlay { position: absolute; bottom: value; right: value; } Example The following example demonstrates how to position text at the bottom right corner of an image − ...
Read MoreCSS grid-template-columns property
The CSS grid-template-columns property is used to define the number and size of columns in a CSS Grid layout. This property allows you to specify how much space each column should take up and how the grid items should be distributed across the columns. Syntax selector { grid-template-columns: value1 value2 ... valueN; } Possible Values ValueDescription autoColumn size adjusts based on content lengthFixed size using px, em, rem, etc. %Percentage of container width frFraction of available space repeat()Repeats a pattern of column sizes Example 1: Auto-Sized Columns ...
Read MoreRole of CSS flex-wrap property no-wrap value
The CSS flex-wrap property with nowrap value prevents flex items from wrapping to new lines, keeping all items on a single row even if they overflow the container. Syntax selector { flex-wrap: nowrap; } Example The following example demonstrates how nowrap forces all flex items to stay on one line − .mycontainer { display: flex; background-color: orange; ...
Read More