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
Request Metrics real user monitoring
Request Metrics real user monitoring
  • Animating CSS3 Transforms with MooTools Fx
  • Create a CSS Flipping Animation

    Create a CSS Flipping Animation

    CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there’s…

  • iPad Detection Using JavaScript or PHP

    iPad Detection Using JavaScript or PHP

    The hottest device out there right now seems to be the iPad. iPad this, iPad that, iPod your mom. I’m underwhelmed with the device but that doesn’t mean I shouldn’t try to account for such devices on the websites I create. In Apple’s…

  • Detect Pseudo-Element Animation Support

Source link
spot_img

Related articles

Kaspersky industrial threat report for Q1 2025

Trends Relative stability from quarter to quarter. The percentage of ICS computers on which malicious objects were blocked remained...

Can you put 3200mhz RAM in a 2666mhz Motherboard?

For anyone looking to upgrade their computer, one of the most important factors is making sure that everything...

10 Best Android Phones of 2025, Tested and Reviewed

Other Phones to ConsiderPixel 9 Photograph: Julian ChokkattuWe test a ton of Android phones. We like the ones below,...