Is using the logo tag in sprites good or bad?

后端 未结 14 925
攒了一身酷
攒了一身酷 2021-02-05 05:31

When building web pages, one of my colleagues displays any logo using the CSS background-image property, rather than embedding the image using an HTML t

14条回答
  •  忘掉有多难
    2021-02-05 05:38

    A logo is content - that is correct. And you would probably happy when a search bot grabs it.

    But some websites like to apply a :hover style on their logos. Now, you're trapped.

    But you can do the following, which is semantically correct. If you want to learn more about that you can read a great article about this issue by Harry Roberts.

    HTML

    
        
    
    

    CSS

    body > #head a#header-logo {
        background-image: url(/img/assets/logo-header-sprite.png);
        background-position: left top;
    }
    body > #head a#header-logo:hover {
        background-position: left -50%;
    }
    body > #head a#header-logo img {
        visibility: hidden;
    }
    

提交回复
热议问题