Force: img:after funktioniert nicht p:after schon

Beitrag lesen

Moin!

Ich wollte gerne zu jedem Bild automatisch, per CSS einen Text hinzufügen. Die Forensuche hat mich auf img:after (img::after?) gebracht. Allerdings funktioniert das hier im Mozilla 1.7 / FF 1.5 nicht. Wenn ich statt "img" "p" nehme, dann erscheint korrekt, hinter jedem <p> der angegebene Content. Hier ein Beispiel:

<html>
  <head>
    <style type="text/css">
      img {
        display:block;
      }

img:after {
        content:attr(alt);
        display:block;
      }

p:after {
        content:attr(class);
      }
    </style>
  </head>
  <body>
    <p class="gibtsnicht">
      <img alt="Google Logo" src="http://www.google.de/images/logo_sm.gif"/>
    </p>
  </body>
</html>


> Hier wird das alt-attribut des img nicht angezeigt. das class-attribut von p aber schon.  
>   
>   
> Ist das ein bekannter bug? Mache ich was falsch? Oder hat jemand einen Tipp, was ich sonst noch unternehmen könnte?  
> -- Skeeve  
  
  
Hey Skeeve,  
  
das alt Attribut wird bei FF und Mozilla gar nicht angezeigt. Probiers mal mit dem title Attribut.  
~~~html
  
<html>  
  <head>  
    <style type="text/css">  
      img {  
        display:block;  
      }  
  
      img:after {  
        content:attr(title);  
        display:block;  
      }  
  
      p:after {  
        content:attr(class);  
      }  
    </style>  
  </head>  
  <body>  
    <p class="gibtsnicht">  
      <img title="Google Logo" src="http://www.google.de/images/logo_sm.gif"/>  
    </p>  
  </body>  
</html>