How to style the string of an tag?

前端 未结 6 1276
孤独总比滥情好
孤独总比滥情好 2020-12-11 09:08

Is there a way to style the alt? With javascript? With pseudo attributes? like this:

\"<h1This is the caption&l         


        
6条回答
  •  无人及你
    2020-12-11 09:46

    It's the alt attribute, not tag, and it's not possible to style it directly. It's simply a piece of text that is displayed if the image fails to load. You can style the element though and it will affect the styling of the alternative text in most browsers (though not IE).

    If you were referring to the tooltip that appears in some browsers when you hover over an image, that's achieved with the title attribute and works on all elements, not just images. The alt attribute is also used by IE for this purpose on images, but this is not standard. Either way, title tooltips cannot be styled. If you need fancier tooltips, you'll have to create your own. I imagine there's a plethora of such things out there.

提交回复
热议问题