Case Insensitive CSS Attribute Selector

Date:

Share post:

CSS selectors never cease to amaze me in how powerful they can be in matching complex patterns. Most of that flexibility is in parent/child/sibling relationships, very seldomly in value matching. Consider my surprise when I learned that CSS allows matching attribute values regardless off case!

Adding a {space}i to the attribute selector brackets will make the attribute value search case insensitive:

/* case sensitive, only matches "example" */
[class=example] {
  background: pink;
}

/* case insensitive, matches "example", "eXampLe", etc. */
[class=example i] {
  background: lightblue;
}

The use cases for this i flag are likely very limited, especially if this flag is knew knowledge for you and you’re used to a standard lower-case standard. A loose CSS classname standard will have and would continue to lead to problems, so use this case insensitivity flag sparingly!

Request Metrics real user monitoring

Source link
spot_img

Related articles

GOLD SALEM’s Warlock operation joins busy ransomware landscape – Sophos News

Counter Threat Unitâ„¢ (CTU) researchers are monitoring a threat group that refers to itself as Warlock Group. The...

MSI Gaming RTX 4090 X Trio (24GB) Graphics Card Review

If you’re looking for a state-of-the-art graphics card to take gaming visuals to the next level, then consider...

How to Troubleshoot Lovable AI App Builder

Lovable AI App Builder empowers anyone to create full-stack web apps using simple English prompts, no coding required....