I have a page with many images, here is an example:
<section>
<div><img src="capas/livro1.jpg" alt="Harry Potter e a Pedra Filosofal"></div>
<div><img src="capas/livro2.jpg" alt="Harry Potter e a Câmara Secreta"></div>
<div><img src="capas/livro3.jpg" alt="Harry Potter e o Prisioneiro de Azkaban"></div>
<div><img src="capas/livro4.jpg" alt="Harry Potter e o Cálice de Fogo"></div>
<div><img src="capas/livro5.jpg" alt="Harry Potter e o Enigma do Príncipe"></div>
<div><img src="capas/livro6.jpg" alt="Harry Potter e a Ordem da Fênix"></div>
<div><img src="capas/livro7.jpg" alt="Harry Potter e as Relíquias da Morte"></div>
<div><img src="capas/livro8.jpg" alt="Pai Rico, Pai Pobre"></div>
<div><img src="capas/livro9.jpg" alt="Quem Mexeu no Meu Queijo?"></div>
<div><img src="capas/livro10.jpg" alt="O Guia do Pão Duro"></div>
.
.
.
</section>
I'd like to show tooltip without using title
. Is it possible using only HTML, CSS or JavaScript?
Something like this:
Thanks.
Forgoing the fact that
alt
should not be used for a tool tip, really you should usetitle
, or better stillfigure
andfigcaption
, you can do this with CSS alone.Use the
:after
psuedo element withhover
then usecontent:attr(alt)
to get the value of the alt attribute.EDIT : Annoyingly this doesn't work in microsoft browsers as they don't support
img::after
.Here's how I'd actually do it with more semantically correct tags
Going this route you can have additional styling within the tool tip if needed