What's the correct way to hide the

tag an

2019-03-23 11:04发布

The website I am working on uses an image defined in CSS as the main logo. The html code looks like this:

<h1>Something.com | The best something ever</h1>

I would like to display just the image defined in CSS and pass the information from the h1 tag to the search enginges only.

What's the correct way to do this? Google is very strict about this, I know that display:none is wrong, what about visibility: hidden ?

Thanks in advance!

标签: html css seo
10条回答
地球回转人心会变
2楼-- · 2019-03-23 11:40

You should be fine with visibility: hidden.

That said, if your image is part of the content (and I would dare to say that a company logo is content, not presentation), and you care about accessible html, you should consider changing your code to include the image as a img element with title and alternate text, instead of a css background-image.

Additionally, if you hope to attract search engines to the keywords inside the <h1> element, you might want to include those words more than once in the page. The page title is a much more relevant place than the h1 element, for example.

查看更多
Viruses.
3楼-- · 2019-03-23 11:42

Resizing the block would work:

h1 {
    overflow: hidden;
    width: 1px;
    height: 1px;
}
查看更多
你好瞎i
4楼-- · 2019-03-23 11:49

set the image as the background of your h1 (set the width/height so it fits) then set your text-indent to something crazy like -9999px. That way when css is disabled (such as being crawled) the bot will see the text in the header instead of the background.

example:

CSS

#myHeader {
width:200px;
height:50px;
background: url('lcoation/of/the/image.jpg') top left no-repeat;
text-indent:-9999px;
}

HTML

<body>
...
<h1 id='myHeader'>HELLO WORLD</h1>
...
</body>
查看更多
太酷不给撩
5楼-- · 2019-03-23 11:51

You're not going to get good SEO results if you, first hide the h1, and second use generic phrases inside the h1.

Don't just use the h1 for sizing, you can use classes to style.

H1 tags should contain keyword rich information such as:

Automotive Repair

Automotive repair being the keyword that relates to the particular page I'm theoretically working on.

Hope that makes sense.

查看更多
Lonely孤独者°
6楼-- · 2019-03-23 11:51

I think that visibility: hidden; would work fine. Have you tried it yet?

查看更多
我想做一个坏孩纸
7楼-- · 2019-03-23 11:55

Does your web site consist of just one single page?

Otherwise you should put the headline of each page in the h1 tag, not the tagline of the site. Repeating the same headline on every page would make it pretty much useless.

查看更多
登录 后发表回答