问题原文
原帖链接 · PetaspeedBeaver · CC BY-SA 3.0
When coding pages by hand, I sometimes want to skip having to write all those <p> tags and use:
<pre>
<h2>Heading written as usual is no problem within a pre</h2>
<i>First paragraph</i> is here.
This is the second paragraph, but since I use the pre-tag I don't need to use the p tag to get a space in between the two.
Next paragraph etc …
</pre>
Which if css:
pre {
whitespace: normal
and same font as the regular text is set for<pre>s will render something like this:
Heading written as usual is no problem within a pre
First paragraph is here.
This is the second paragraph, but since I use the pre-tag I don't need to use the p tag to get a space in between the two.
Next paragraph etc …
Is using the <pre> to save on typing some <p>s in this way likely to affect SEO? If so, why and how?
已采纳解答
原帖链接 · Simon Hayter · CC BY-SA 3.0
Both Google & Bing does not consider markup as a ranking factor, it uses markup to understand content and not directly reward, this includes Schema and other micro data formats.
So using <pre> or <p> is not going to going to make any real world differences in terms of rankings but that's not to say you should treat <pre> the same as <p> because some e-readers and browsers may render those differently, never mind it's also lazy to do this way.
Your gap between elements should come from the CSS not using a hack like PRE because as mentioned browsers including different versions of those browsers can render them differently if not set by the CSS. If you want everything to look the same across devices and browsers then use the CSS, that's what it was designed for.
Best practice would be to mimic the style of <pre><code> by adding a container around the <p> with something like:
<!-- HTML -->
<div class="pre">
<h2>Identical Header</h2>
<p>This looks identical to PRE</p>
<p>I have a gap because P and H have margin-bottom</p>
</div>
/* CSS */
.pre {
whitespace: normal;
font-size: 1em;
font-family: 'Same Font As PRE or CODE';
}
.pre h1, .pre h2, .pre h3, .pre h4, .pre h5 {
margin-bottom: 1.5em;
font-size: 1.5em
font-family: inherit;
}
.pre p {
font-size: inherit;
font-family: inherit;
margin-bottom: 1em;
}
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
