CSS Articles

Page 104 of 130

Create a transparent box with CSS

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 880 Views

Creating a transparent box in CSS allows you to make elements semi-transparent, revealing content behind them. The most common approach is using the opacity property, which controls the transparency level of an entire element. Syntax selector { opacity: value; } Possible Values ValueDescription 0Completely transparent (invisible) 0.1 - 0.9Semi-transparent (decimal values) 1Completely opaque (default) Example The following example demonstrates how to create transparent boxes with different opacity levels − div { ...

Read More

Set the opacity for the background color with CSS

varun
varun
Updated on 15-Mar-2026 279 Views

To set the opacity for the background color, use the RGBA color values or the opacity property. RGBA allows you to control the transparency of just the background, while the opacity property affects the entire element including text and child elements. Syntax /* Using RGBA for background opacity */ selector { background-color: rgba(red, green, blue, alpha); } /* Using opacity property */ selector { opacity: value; } Method 1: Using RGBA Values The RGBA color model allows you to specify opacity only for the background ...

Read More

Add transparency to the background with CSS

usharani
usharani
Updated on 15-Mar-2026 343 Views

The CSS opacity property is used to add transparency to the background of an element. The property accepts values from 0 (completely transparent) to 1 (completely opaque), allowing you to create various levels of transparency effects. Syntax selector { opacity: value; } Possible Values ValueDescription 0Completely transparent (invisible) 0.1 - 0.9Partially transparent with varying degrees 1Completely opaque (default) Example: Different Opacity Levels The following example demonstrates different transparency levels using the opacity property − div { ...

Read More

Role of CSS :visited Selector

varma
varma
Updated on 15-Mar-2026 253 Views

The CSS :visited selector is used to style links that have been visited by the user. This pseudo-class allows you to apply different styles to links based on whether they have been clicked before, providing visual feedback to users about their browsing history. Syntax a:visited { property: value; } Example: Basic Visited Link Styling The following example demonstrates how to style visited links with different colors and properties − a:link { color: ...

Read More

Role of CSS: valid Selector

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 223 Views

The CSS :valid selector is used to style form input elements that contain valid values according to their specified type or validation constraints. This pseudo-class selector automatically applies styles when the input meets the validation criteria. Syntax input:valid { /* styles for valid inputs */ } Example: Email Validation Styling The following example demonstrates how to style email inputs with valid email addresses − input[type="email"] { padding: 10px; ...

Read More

Role of CSS :target Selector

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 327 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

Style the document's root element with CSS

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 123 Views

The CSS :root pseudo-class selector targets the document's root element. In HTML documents, this is the element. It's commonly used to define CSS custom properties (variables) and global styles. Syntax :root { property: value; } Example 1: Basic Root Element Styling The following example applies background and text color to the root element − :root { background: blue; color: white; ...

Read More

CSS position: sticky;

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 429 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 :required Selector

Sreemaha
Sreemaha
Updated on 15-Mar-2026 236 Views

The CSS :required pseudo-class selector is used to target form elements that have the required attribute. This selector allows you to apply specific styles to required form fields, helping users identify which fields are mandatory to fill out. Syntax :required { /* CSS properties */ } input:required { /* Styles for required input elements */ } Example: Styling Required Input Fields The following example demonstrates how to style required input fields with a distinctive background color − ...

Read More

Role of CSS :read-write Selector

usharani
usharani
Updated on 15-Mar-2026 134 Views

The CSS :read-write pseudo-class selector targets form elements that are both readable and writable by the user. This selector applies styles specifically to input fields and textareas that can be edited, excluding read-only elements. Syntax :read-write { /* CSS properties */ } Elements Targeted The :read-write selector matches: elements without the readonly attribute elements without the readonly attribute Elements with contenteditable="true" Example The following example demonstrates how :read-write styles only the editable input field − ...

Read More
Showing 1031–1040 of 1,299 articles
« Prev 1 102 103 104 105 106 130 Next »
Advertisements