For the following image html:
<img src="/some.png" alt="something" />
In CSS, you can target an img element with a specific alt value:
img[alt="something"] {
width: 5em;
}
How can I select all img elements with text in the alt attribute? I was thinking of something like:
img[alt="*"]
but that doesn’t seem to work. Any ideas?
You can target elements which have an
altattribute like thisI believe this will also match those with an empty
altattribute however. I don’t think you can specifically target those with a nonempty value. You could write a rule to match those with empty values and undo ignore the rules which would otherwise be applied (via!important) although that gets messy.