Doubt about HTML regarding the alt=" command

Asked

Viewed 406 times

-1

The thing is, my image is not showing the text I put in alt=" when I put the mouse on top.

<!DOCTYPE html>
<html>
<head>
    <title>teste</title>
</head>
<body>
    <img src="foto.jpg" alt="foto" />
</body>
</html> 

Is there something wrong with the script? I have a website hosted on 000webhost, and it also is not displaying what I wrote in alt=" ".

  • 1
  • You have to put the attribute title to display some text.

  • 1

    Search the difference between alt and title.

  • As already said, what you want is the attribute title, but be sure to use the alt for the sake of accessibility

  • I get it, thank you!

  • @LINQ does not see how the answers there could solve the problem, I mean is a great addition and explains what is, but will not solve, I understand that the title of the question is bad and makes understand the contrary, but the body of the question makes clearer the need. I think someone can formulate a simple answer and point out this question link as an addendum.

Show 1 more comment

2 answers

1

The attribute alt="" in images does not serve to display the desired tooltip, the purpose of this attribute is explained better in:

What you want is to display the tooltip.

It is worth noting that maybe some browsers like IE6 displayed such a tooltip when using the attribute alt=, but it doesn’t mean it was right.

So to display such tooltype the "global" attribute to be used is the title="", of course it is worth noting that he has varied behavior sometimes, as in elements <link ...>:

Then it should stay that way:

<img src="https://cdn.sstatic.net/Sites/br/img/sprites.svg?v=9a80d5fa584d" alt="sprites do stack overflow" title="sprites do stack overflow" />

Note that although you have put the text on alt and in title in equal ways, both have different goals, although both are eventually used in SEO for description, the behavior in screen readers is variant, although it is more interesting to take a look at the attributes aria:

But screen readers goes a little beyond the question, I leave the link just chance you are interested in delving into the subject.

-1

Alt is an alternate text that appears if the image cannot be loaded

<img src="naocarrega.png" alt= "Imagem nao carregada">
<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="Este texto nao aparece" width="110" height="50"/>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.