Front End Technology Articles

Page 483 of 652

Using Data-Attributes (data-*) in CSS

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

CSS data attributes allow you to store custom information on HTML elements and access it through CSS selectors and the attr() function. These attributes must start with data- followed by a custom name. Syntax /* Selecting elements with specific data attributes */ [data-attribute] { /* styles */ } [data-attribute="value"] { /* styles */ } /* Using data attribute values in CSS */ element::before { content: attr(data-attribute); } Example 1: Interactive Food Menu with Data Attributes This example demonstrates how data attributes can store additional information and interact with JavaScript ...

Read More

Get and Set CSS Variables with JavaScript

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 14K+ Views

To get and set CSS variables with JavaScript, we can use various methods. The getComputedStyle() method gives an object which includes all the styles applied to the target element. The getPropertyValue() method is used to obtain the desired property from the computed styles. The setProperty() method is used to change the value of CSS variable. Syntax /* Getting CSS Variable */ getComputedStyle(element).getPropertyValue('--variable-name'); /* Setting CSS Variable */ element.style.setProperty('--variable-name', 'value'); Methods Used MethodPurpose getComputedStyle()Returns computed styles of an element getPropertyValue()Gets the value of a specific CSS property setProperty()Sets the value of a CSS ...

Read More

Using CSS :placeholder-shown to Customize Styles for Empty Text Input

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 414 Views

The CSS :placeholder-shown pseudo-class is used to style input elements when they are displaying placeholder text. This pseudo-class allows you to customize the appearance of empty text fields that show placeholder hints to users. Syntax input:placeholder-shown { /* CSS properties */ } Method 1: Setting Border Color You can change the border color of input fields when they display placeholder text using the border-color property − input { padding: 10px; ...

Read More

How to Create a Checkmark / Tick with CSS

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

Creating a checkmark (tick) symbol with pure CSS is useful for custom form controls, success indicators, and interactive elements. CSS allows us to create checkmarks using borders, pseudo-elements, or transforms without requiring icon fonts or images. Syntax .checkmark { /* Create using borders and rotation */ border-right: 2px solid color; border-bottom: 2px solid color; transform: rotate(45deg); } Method 1: Using Borders and Transform This method creates a checkmark by styling a div with bottom and right borders, then ...

Read More

Difference Between Pseudo-Class and Pseudo-Element in CSS

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 4K+ Views

CSS pseudo-classes and pseudo-elements are powerful selectors that allow you to style elements based on their state or create virtual elements. Understanding the difference between them is crucial for effective CSS styling. Syntax Pseudo-classes use a single colon (:) while pseudo-elements use a double colon (::) − /* Pseudo-class syntax */ selector:pseudo-class { property: value; } /* Pseudo-element syntax */ selector::pseudo-element { property: value; } Pseudo-Class A pseudo-class targets elements in a specific state or position, such as :hover, :active, :first-child, or :last-child. They ...

Read More

HTML Tables with Fixed Header on Scroll in CSS

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 26K+ Views

We can create HTML tables with fixed header on scroll using CSS. It helps to increase readability as user doesn't have to scroll everytime to check the table header. In this article, we will learn and understand two different approaches for HTML tables with fixed header on scroll in CSS. We have a table inside a div element with class name as container. Our task is to fix HTML table header on scroll using CSS. Syntax /* Method 1: Using position sticky */ th { position: sticky; top: ...

Read More

CSS Selector to Select Elements Not Having Certain Class / Attribute / Type

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 3K+ Views

Using the CSS :not() pseudo-class, we can refine our styling by selecting those elements which do not have a specific value or does not match a selector. Syntax selector:not(selector) { property: value; } Select Elements Not Having a Child Selector To select elements not having a child selector, use the :not pseudo-class in CSS. Here, we have a child selector. The CSS child selector is used to select all the child elements with a particular parent element. It selects all the elements that are children of i.e. ...

Read More

Latest CSS Properties and APIs for Web Design in 2020

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 210 Views

CSS continues to evolve with new properties and APIs that enhance web design capabilities. Here are some of the latest CSS features that provide developers with powerful tools for creating modern, responsive, and accessible websites. Key CSS Properties focus-within Pseudo-class The :focus-within pseudo-class selects elements that contain a focused element, improving focus accessibility for complex components. .form-group { padding: 20px; border: 2px solid #ccc; ...

Read More

Disabling Pull-to-Refresh Feature on Mobile Browsers using CSS

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

The CSS overscroll-behavior property controls what happens when a user scrolls beyond the boundary of a scrollable area. On mobile browsers, this feature is particularly useful for disabling the pull-to-refresh gesture that occurs when users scroll past the top of a webpage. Syntax selector { overscroll-behavior: value; } Possible Values ValueDescription autoDefault browser behavior (allows pull-to-refresh) containPrevents scrolling from affecting parent elements noneCompletely disables overscroll effects including pull-to-refresh Example 1: Disabling Pull-to-Refresh on Body To disable pull-to-refresh on the entire page, apply overscroll-behavior: none to the ...

Read More

CSS Updates - New Properties for Styling Text Decorations & Underlines

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 223 Views

With the introduction of new text-decoration properties, we can now style text decorations with greater control and precision. The text-decoration property serves as shorthand for multiple decoration properties, while specific properties like text-underline-offset and text-decoration-skip-ink provide fine-grained control over underlines and text decoration behavior. Syntax selector { text-decoration: line style color thickness; } The text-decoration Shorthand Property The text-decoration property is shorthand for text-decoration-line, text-decoration-style, text-decoration-color, and text-decoration-thickness. Additional properties like text-decoration-skip-ink and text-underline-offset must be specified separately. Example Let us see an example to use the shorthand ...

Read More
Showing 4821–4830 of 6,519 articles
« Prev 1 481 482 483 484 485 652 Next »
Advertisements