CSS Articles

Page 42 of 130

What is contextual selector in CSS?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 2K+ Views

Contextual selectors allow developers to apply styles to elements based on their position within the HTML document structure. These selectors target elements that exist within a specific context or parent-child relationship, giving you precise control over styling without affecting similar elements elsewhere on the page. Syntax parent-selector descendant-selector { property: value; } The contextual selector consists of two or more selectors separated by a space, where the last selector is the target element and the preceding selectors define its context. Example 1: Basic Element Selection First, let's see what ...

Read More

Making a Div vertically scrollable using CSS

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 686 Views

Making a div vertically scrollable is essential when content exceeds the container's height, preventing layout disruption and maintaining website responsiveness. This technique allows users to scroll through content within a fixed−height container. Syntax selector { overflow: value; /* or for specific axes */ overflow-x: value; overflow-y: value; } Possible Values ValueDescription visibleContent overflows the container (default) hiddenContent is clipped, no scrollbar scrollAlways shows scrollbar autoShows scrollbar only when needed Method 1: Using overflow-y Property ...

Read More

Is it possible to prevent the users from taking screenshot of webpage?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 20K+ Views

While browsing the internet, users might need to capture screenshots to share information. However, webpages containing sensitive content may require protection from unauthorized screenshots. Though complete prevention is impossible, CSS provides several techniques to discourage screenshot attempts. Why Screenshot Prevention is Limited Screenshot functionality is controlled by the operating system − Windows (Win + PrtScn), macOS (Cmd + Shift + 3), and mobile devices all have built-in screenshot capabilities. Web technologies like HTML, CSS, and JavaScript cannot override these OS-level functions. However, we can implement deterrent measures using CSS properties. Method 1: Hiding Content During Print ...

Read More

How to place image or video inside silhouette?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 301 Views

The silhouette effect creates visually striking designs by placing images or videos inside the outline of a shape, person, or object. Using CSS's mix-blend-mode property, we can blend content with silhouette backgrounds to achieve this creative effect. Syntax selector { mix-blend-mode: value; } Possible Values ValueDescription normalNo blending (default) multiplyMultiplies colors, creating darker results screenInverts, multiplies, and inverts again for lighter results darkenKeeps the darkest color from each channel Example 1: Basic Mix-Blend Mode Here's how mix-blend-mode works with overlapping colored circles − ...

Read More

How to hide the insertion caret in a webpage using CSS?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 3K+ Views

The insertion caret is a blinking vertical line that appears in text input fields to indicate where text will be inserted. This visual indicator helps users know the current text insertion point. Using CSS, you can control the appearance of this caret, including making it completely invisible. Syntax selector { caret-color: value; } Possible Values ValueDescription autoBrowser default caret color (usually black) transparentMakes the caret invisible colorAny valid CSS color value (red, #ff0000, rgb(255, 0, 0)) Example: Hiding the Insertion Caret The following example demonstrates how ...

Read More

Animating a rainbow heart from a square using CSS?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 436 Views

We can create visually appealing animations using CSS that transform shapes and change colors dynamically. CSS provides powerful animation properties that make it easy to create engaging visual effects on webpages. In this article, we will create an animated rainbow heart that transforms from a square shape and cycles through different colors every 3 seconds using CSS keyframes and transforms. Syntax @keyframes animation-name { 0% { property: value; } 50% { property: value; } 100% { property: value; } } selector { ...

Read More

Adding a mask to an image using CSS

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 377 Views

The CSS mask-image property allows you to create a layer over an element that can hide parts of it either partially or completely. This property is particularly useful for creating visual effects on images and text. Syntax selector { mask-image: none | | linear-gradient() | radial-gradient() | initial | inherit; } Possible Values ValueDescription noneNo mask is applied (default) Uses an image as the mask linear-gradient()Creates a linear gradient mask radial-gradient()Creates a circular gradient mask initialSets the property to its default value inheritInherits the value from parent element ...

Read More

Difference between resetting and normalizing CSS?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 4K+ Views

Developers want HTML elements to look the same across all browsers. However, each browser applies its own default styles to HTML elements, which can cause inconsistencies. For example, heading tags may have different sizes, fonts, margins, or padding depending on the browser used. This tutorial explains CSS resetting and normalizing techniques, and the key differences between them. What is CSS Resetting? CSS resetting is a technique that removes all default browser styles by setting them to null or uniform values. This approach ensures a completely clean slate for styling, eliminating cross-browser inconsistencies caused by different user agent ...

Read More

Why does div display: table-row ignore margin?

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 1K+ Views

The CSS display: table-row property ignores margin because table elements follow the CSS table model, where margins don't apply to internal table components like table-row and table-cell. Instead, spacing is controlled by the border-spacing property or by applying margin to nested elements. Syntax .element { display: table-row; /* Margins will be ignored */ margin: 20px; /* This won't work */ } Why Table Rows Ignore Margin The CSS specification states that margin properties don't apply to elements with display: table-row, table-row-group, table-header-group, table-footer-group, table-column, table-column-group, or ...

Read More

Maintenance with CSS

Tanmay Chandhok
Tanmay Chandhok
Updated on 15-Mar-2026 1K+ Views

CSS (Cascading Style Sheets) is used to style HTML elements and is responsible for the look and feel of webpages. It allows you to change colors, backgrounds, fonts, spacing, and layout. One of CSS's greatest strengths is its maintainability — the ability to make site-wide changes quickly and efficiently. In this article, we'll explore how CSS makes web development maintenance easier and examine its key benefits and limitations. Advantages of CSS Following are the major advantages of using CSS − Time Saving Through Reusability CSS allows you to write styles once and reuse them across ...

Read More
Showing 411–420 of 1,299 articles
« Prev 1 40 41 42 43 44 130 Next »
Advertisements