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

What cybercriminals do with their money (Part 4) – Sophos News

Content warning: Because of the nature of some of the activities we discovered, this series of articles contains...

How I Fixed Two Lenovo Yoga Laptops

The other day, my wife came home with a couple of laptops belonging to a close friend of...

How It Works and What Are Its Advantages?

Electronic check-in for events has revolutionized the way organizers manage access and attendee accreditation. This technology not only...

Jeff Bezos is reportedly courting Trump after public spat with Musk

Jeff Bezos is apparently trying to capitalize on the recent blow-up between President Donald Trump and Elon Musk,...