How to style the string of an tag?

前端 未结 6 1277
孤独总比滥情好
孤独总比滥情好 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 10:01

    What you are trying to achieve is styling alt text when image is somehow not displayed. Alt is not an element so you can't style it directly but what you can do to achieve the desired result is by setting font-size on img element.

    JSfiddle Demo

    img{
      font-size: 16px;
    }
    
    .small-alt-text{
      font-size:8px;
    }
    .big-alt-text{
      font-size:24px;
    }
    Image failed to load
    
    Image failed to load
    Image failed to load

提交回复
热议问题