开发者

Redefine <h1>, <h2>, ... on-the-fly?

I am working on a web page that now needs to be Google-optimized. Currently a lot of title head lines are described by custom css classes. So for example the class .megafat is for a h开发者_Python百科ead-liner that should now sit inside an <h1>-Tag. On the other hand on other page something that needs to be <h1> might have another font. Therefore it is not possible to "rename" those css-classes to h1, h2, h3, h4 consistently.

My question: Is it possible to stripe all css font definitions out of <h1> such that this looks like plain text so I can add my custom css class?


Yes, you can use a CSS reset to wipe out all default styling.

Here's a good HTML5-friendly one: http://html5doctor.com/html-5-reset-stylesheet/

If the header tags are all you want affected, you'll need to remove the stuff that doesn't apply. I find it good practice to always do a reset of everything, though, as it means every bit of styling is under your complete control.


Google cares about your page's structure and content, it doesn't care about appearance. It's unclear from your question, but you may be talking about one or another of two cases.

Case 1: Your h1 and h2 are styled in a certain way that you want to remove for google's benefit (to improve your ranking?)

<h1 class="megafat">Fancy Mega-Fat Heading</h1>

Case 2: You have a "megafat" class that makes things look like headings, but they really aren't

<div class="megafat">This is plain text but is pretending to be a heading</div>

In case 1 you don't have to do anything, google cares (as I said) about the structure in this case, and an h1 is a top heading, regardless of how you've made it look.

In case 2, changing the font/styles via CSS still has no effect, because it's still "just" a div, not really a heading. You would have to actually replace the div DOM element with an h1 element for it to make a difference to google.

If you're talking about something other than Google's analysis of your page, such as what they show in the search results preview, my answer could be totally off.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜