Mobile app version of vmapp.org
Login or Join
Yeniel560

: I tried it and it works perfectly for me. Note that the color and font-size properties won't have any effect in Chrome, since no text gets displayed. (Firefox displays the alt text if the

@Yeniel560

I tried it and it works perfectly for me. Note that the color and font-size properties won't have any effect in Chrome, since no text gets displayed. (Firefox displays the alt text if the image cannot be found.) Using the width property, for example, shows that it works fine. I'll post my code below for you to see.

However, to your original question, targeting what is essentially a "free text" field in CSS is prone to mishap. It's very easy to change an alt attribute without thinking about repercussions in CSS (as opposed to changing a class name where it should be obvious).

Furthermore, since you are already targeting an ID you only need to use that selector - an ID can only be used once per page.



<!DOCTYPE html>
<html>
<head>
<style>img#logo[alt="Site Title"] { width:200px }</style>
</head>
<body>
<img alt="Site Title" src="bullet.png" id="logo" />
</body>
</html>

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Yeniel560

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme