Replacing H1 text with a logo image: best method for SEO and accessibility?

前端 未结 15 2205
渐次进展
渐次进展 2020-11-28 00:16

It seems like there are a few different techniques out there, so I was hoping to get a \"definitive\" answer on this...

On a website, it\'s common practice to create

15条回答
  •  借酒劲吻你
    2020-11-28 01:03

    If accessibility reasons is important then use the first variant (when customer want to see image without styles)

    
    

    No need to conform imaginary SEO requirements, because the HTML code above has correct structure and only you should decide does this suitable for you visitors.

    Also you can use the variant with less HTML code

    Stack Overflow

    /* position code, it may be absolute position or normal - depends on other parts of your site */
    #logo {
      ...
    }
    
    #logo a {
       display:block;
       width: actual_image_width;
       height: actual_image_height;
       background: url(image.png) no-repeat left top;
    }
    
    /* for accessibility reasons - without styles variant*/
    #logo a span {display: none}
    

    Please note that I have removed all other CSS styles and hacks because they didn't correspond to the task. They may be usefull in particular cases only.

提交回复
热议问题