Arjun Thakur

Arjun Thakur

749 Articles Published

Articles by Arjun Thakur

Page 24 of 75

CSS transition-duration property

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 126 Views

The CSS transition-duration property is used to set the duration of CSS transitions. It specifies how long a transition takes to complete when an element changes from one state to another. Syntax selector { transition-duration: time; } Possible Values ValueDescription timeDuration in seconds (s) or milliseconds (ms) 0sNo transition (default) inheritInherits from parent element Example: Basic Transition Duration The following example demonstrates a 2-second transition duration on hover − .box { ...

Read More

Build a radial gradient with the shape of a circle

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 294 Views

The CSS radial-gradient property allows you to create circular gradient effects by specifying the circle shape parameter. This creates a gradient that radiates outward from a central point in a perfect circular pattern. Syntax selector { background: radial-gradient(circle, color1, color2, color3, ...); } Example: Circle-Shaped Radial Gradient The following example creates a circular radial gradient with multiple colors − #demo { height: 300px; width: ...

Read More

Selects all elements with a lang attribute value starting with "en" with CSS

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 275 Views

The CSS [attribute|="value"] selector is used to select elements with a specified attribute value that starts with the given value. This selector is particularly useful for language codes, where you want to select elements with lang attributes starting with "en" (like "en", "en-US", "en-GB", etc.). Syntax [attribute|="value"] { /* CSS properties */ } Example The following example selects all elements with a lang attribute value starting with "en" and applies an orange border ? ...

Read More

Add a background color to the form input with CSS

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 8K+ Views

The CSS background-color property is used to add background color to form input elements. This property allows you to customize the appearance of input fields by setting their background to any color value. Syntax input { background-color: value; } Possible Values ValueDescription color namePredefined color names like red, blue, gray hex codeHexadecimal values like #FF5733, #000000 RGBRGB values like rgb(255, 87, 51) transparentMakes the background transparent Example The following example applies a gray background color to text input fields − ...

Read More

How to create a responsive image gallery with CSS

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 490 Views

A responsive image gallery adapts to different screen sizes using CSS media queries and flexible layouts. This allows images to display properly on desktop, tablet, and mobile devices by adjusting the number of columns and image sizes automatically. Syntax .gallery-container { width: percentage; float: left; } @media only screen and (max-width: breakpoint) { .gallery-container { width: new-percentage; } } Example The following example creates a responsive image gallery that ...

Read More

Role of CSS :target Selector

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 349 Views

The CSS :target selector is a powerful pseudo-class that targets an element whose id matches the fragment identifier in the current URL. This allows you to style elements when they are directly accessed through anchor links, creating smooth navigation highlighting and interactive content sections. Syntax :target { /* CSS properties */ } How :target Works When a user clicks on a link with a fragment identifier (like #section1), the browser navigates to the element with that id. The :target selector automatically applies styles to that specific element, making it visually ...

Read More

CSS position: sticky;

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 443 Views

The CSS position: sticky property creates a hybrid positioning behavior where an element toggles between relative and fixed positioning depending on the scroll position. The element is positioned relative until it reaches a specified threshold, then becomes fixed in place. Syntax selector { position: sticky; top: value; } How It Works A sticky element behaves like position: relative until the viewport reaches the defined offset position. Once the threshold is met, it becomes position: fixed and sticks to that position while scrolling. Example: Basic Sticky ...

Read More

Role of CSS :only-child Selector

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 207 Views

The CSS :only-child selector targets elements that are the only child of their parent element. It styles elements when they have no siblings, making it useful for applying special formatting to isolated elements. Syntax element:only-child { property: value; } Example: Styling Only Child Paragraphs The following example demonstrates how the :only-child selector applies styles only to paragraphs that are the sole child of their parent − p:only-child { background-color: orange; ...

Read More

Role of CSS :invalid Selector

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 283 Views

The CSS :invalid pseudo-class selector targets form elements that fail validation constraints. It automatically applies styles to input fields when their values don't meet the specified requirements, providing immediate visual feedback to users. Syntax selector:invalid { property: value; } Example: Email Validation Styling The following example applies a red background to an email input when the value is invalid − input:invalid { background-color: #ffcccc; ...

Read More

Usage of CSS :focus pseudo-class

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 102 Views

The CSS :focus pseudo-class is used to apply styles to form elements when they receive focus (when a user clicks on them or navigates to them using the keyboard). This is particularly useful for improving user experience and accessibility. Syntax selector:focus { property: value; } Example The following example demonstrates how to use the :focus pseudo-class to highlight input fields with an orange background when they are focused − input:focus { ...

Read More
Showing 231–240 of 749 articles
« Prev 1 22 23 24 25 26 75 Next »
Advertisements