CSS Articles

Page 105 of 130

Style elements with a "readonly" attribute with CSS

George John
George John
Updated on 15-Mar-2026 2K+ Views

The CSS :read-only pseudo-class selector is used to style form elements that have the readonly attribute. This selector targets input fields and textareas that users cannot modify. Syntax input:read-only { /* CSS properties */ } textarea:read-only { /* CSS properties */ } /* Target all read-only elements */ :read-only { /* CSS properties */ } Example: Styling Read-Only Input Fields The following example demonstrates how to apply different styles to read-only and editable input fields − ...

Read More

Role of CSS : read-only Selector

vanithasree
vanithasree
Updated on 15-Mar-2026 184 Views

The CSS :read-only selector is used to select form elements that have the readonly attribute set. This pseudo-class targets input fields and textarea elements that users cannot modify, making it useful for styling non-editable form fields differently from editable ones. Syntax :read-only { /* styles */ } input:read-only { /* styles for read-only input elements */ } textarea:read-only { /* styles for read-only textarea elements */ } Example: Basic Read-Only Styling The following example demonstrates how to style read-only input ...

Read More

Style elements with a value outside a specified range with CSS

seetha
seetha
Updated on 15-Mar-2026 218 Views

The CSS :out-of-range pseudo-class selector is used to style elements when their value is outside the specified min and max range. This selector only applies to input elements that have range limitations defined. Syntax input:out-of-range { /* styles */ } Example: Styling Out-of-Range Input The following example demonstrates how to style a number input when the value is outside the specified range − input:out-of-range { border: 3px dashed orange; ...

Read More

Role of CSS :optional Selector

radhakrishna
radhakrishna
Updated on 15-Mar-2026 239 Views

The CSS :optional pseudo-class selector is used to target form elements that do not have the required attribute. This selector is particularly useful for styling optional form fields differently from required ones. Syntax :optional { /* CSS properties */ } /* Target specific optional elements */ input:optional { /* CSS properties */ } Example: Styling Optional Form Fields The following example demonstrates how to style optional input fields with a light blue background while required fields remain with default styling − ...

Read More

Role of CSS :only-child Selector

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 198 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 :only-of-type Selector

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

The CSS :only-of-type pseudo-class selector is used to style elements that are the only child of their specific type within their parent container. It targets elements that have no siblings of the same element type. Syntax element:only-of-type { /* CSS properties */ } Example: Basic Usage The following example demonstrates how :only-of-type selects paragraph elements that are the only element within their parent − p:only-of-type { background: orange; ...

Read More

Methods of 3D transforms with CSS3

mkotla
mkotla
Updated on 15-Mar-2026 82 Views

CSS 3D transforms allow you to manipulate elements in three-dimensional space using the transform property. These methods enable translation, rotation, and scaling along the x, y, and z axes to create depth and perspective effects. Syntax selector { transform: transform-function(values); transform-style: preserve-3d; /* Optional: preserves 3D space for child elements */ } 3D Transform Methods MethodDescription matrix3d(n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n)Transforms element using 16 values of a 4x4 matrix translate3d(x, y, z)Moves element along ...

Read More

Role of CSS :nth-of-type(n) Selector

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

The CSS :nth-of-type(n) selector is used to select and style elements that are the nth child of their specific type within their parent element. This pseudo-class is particularly useful when you want to target specific elements based on their position among siblings of the same tag type. Syntax element:nth-of-type(n) { property: value; } Possible Values ValueDescription numberSelects the element at the specified position (1, 2, 3, etc.) oddSelects all odd-positioned elements of the same type evenSelects all even-positioned elements of the same type an+bSelects elements using a formula (e.g., ...

Read More

X-axis 3D transform with CSS3

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

The CSS rotateX() function is used to rotate an element around its X-axis in 3D space. This creates a horizontal rotation effect, making the element appear to flip vertically. Syntax selector { transform: rotateX(angle); } The angle value can be specified in degrees (deg) or radians (rad). Example The following example demonstrates X-axis 3D rotation by comparing a normal element with a rotated one − div { width: 200px; ...

Read More

Role of CSS :nth-child(n) Selector

George John
George John
Updated on 15-Mar-2026 281 Views

The CSS :nth-child(n) selector allows you to select and style elements based on their position among siblings within a parent element. This powerful pseudo-class selector enables precise targeting of specific child elements without adding extra classes or IDs. Syntax selector:nth-child(n) { property: value; } Possible Values ValueDescription oddSelects every odd-numbered child evenSelects every even-numbered child nSpecific position number (1, 2, 3, etc.) an+bFormula for complex patterns Example 1: Selecting Specific Position The following example styles the fourth paragraph element with an orange background − ...

Read More
Showing 1041–1050 of 1,299 articles
« Prev 1 103 104 105 106 107 130 Next »
Advertisements