Doubts about HTML regarding the command alt="" [duplicate]

-1

This is the following, my image is not showing the text that I put in when I put the mouse over.

<!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 site hosted on 000webhost, and it is not appearing in it either.

    
asked by anonymous 07.08.2018 / 21:26

2 answers

1

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

What you want is to display the tooltip.

It's worth noting that some browsers such as IE6 could display this tooltip when using the alt= attribute, but that does not mean it was right.

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

So it should look like this:

<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 text in alt and title in equal ways, both have different goals, although both are eventually used in SEO for description, behavior in screen readers is variant, despite of being more interesting to take a look at the attributes aria :

But screen readers goes a little further than the question, I leave the link only to have an interest in delving deeper into the subject.

    
07.08.2018 / 22:28
-1

Alt is an alt text that appears if the image can not be loaded

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