Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 943 Bytes

ignore-case-sensitivity-in-a-css-attribute-selector.mdx

File metadata and controls

30 lines (22 loc) · 943 Bytes
category created tags title
Tip
2021-03-23
CSS
Ignore case sensitivity in a CSS attribute selector

By default, CSS attribute selectors are case-sensitive. It means that a[href$=".png"] has effect with the links whose extensions are .png only.

Imagine that you're building a files management application. It would add an icon to a file based on its extension. For example, the following CSS inserts an icon to any .png file.

a[href$='.png']:after {
    content: url(/assets/png.svg);
}

In reality, the files are uploaded by the users and we can't control the file extensions. A png file can be named as .png, .PNG, .pNG.

In order to accept all of these variants, we can add i right before ] in the selector.

a[href$='.png' i]:after {
    content: url(/assets/png.svg);
}

See also