css - 在 HTML5 中为 "just text"使用 p 标签是否有充分的理由?

标签 css html article paragraph

<分区>


想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它.

关闭 8 年前

(如果我应该把这个问题带到另一个网站,请告诉我,因为它是理论上的。)

考虑通常情况

<article class="faux-news">
    <h1>The zombies have arisen</h1>
    <p>Join our reporter as he unravels today's events from Reseda's Northridge Mall this morning.</p>
    <h2>Oh, the humanity!</h2>
    <p>Droves of humanity (living and undead) piled up on either side of the glass doors, one drove from the inside trying to get their filthy hands on some brainz and the other drove trying to get their meticulously manicured hands on the new iBerry. To the living, it was just another crowd to fight for their long since pre-loved tech gadget.</p>
    <h2>Un-undead Victorious</h2>
    <p>So strong were their desire for the mythical iBerry 6, so firm their resolve, that the living easily overcame the re-living. The stampede was too much for the undead, who were simply left for - dead.</p>
    <p>And so the living were spared infection by Zombie Rot on this day. But naturally, rumors are already in circulation about, primarily, the iBerry 7, and secondarily, iBerry 6 fans being zombies to begin with and how there's this big conspiracy bankrolled by the liberals and ancient aliens from Alpha Beta Six.</p>
</article>

对比

<article class="faux-news">
    <h1>The zombies have arisen</h1>
    Join our reporter as he unravels today's events from Reseda's Northridge Mall this morning.
    <h2>Oh, the humanity!</h2>
    Droves of humanity (living and undead) piled up on either side of the glass doors, one drove from the inside trying to get their filthy hands on some brainz and the other drove trying to get their meticulously manicured hands on the new iBerry. To the living, it was just another crowd to fight for their long since pre-loved tech gadget.
    <h2>Un-undead Victorious</h2>
    So strong were their desire for the mythical iBerry 6, so firm their resolve, that the living easily overcame the re-living. The stampede was too much for the undead, who were simply left for - dead.<br>
    And so the living were spared infection by Zombie Rot on this day. But naturally, rumors are already in circulation about, primarily, the iBerry 7, and secondarily, iBerry 6 fans being zombies to begin with and how there's this big conspiracy bankrolled by the liberals and ancient aliens from Alpha Beta Six.
</article>

如果有的话,SEO 对将正文分成段落(而不是通过某些标记作为分隔符)的惩罚是什么?

<br> 可能存在样式问题, 但它可以替换为 <span class="br">或任何可设置样式的标签。

可能存在针对个别段落的样式问题,但这也可以解决 - f.ex。用<p class="i-am-individual">仅针对那些。

是否还有其他问题需要考虑 - 例如与跨浏览器渲染相关的问题?我看不到,但您可能会看到我看不到的东西。

简而言之:跳过那些可能导致大量工作修复未关闭的讨厌的段落化文本有什么危害 <p>标签与“富文本编辑器的用户使用情况”?

最佳答案

“危险”是所有“纯文本”的样式可能不一致,因为无论“纯文本”出现在哪里,您都依赖于继承的样式,并且它可能出现在除 <article> 之外的其他 html 标记中。 .

但这在您的特定情况下可能是完全可以接受的。 另外,通过消除无关的标记并不必做所有必要的工作来在 <p> 中查找和包含“纯文本”,您将获得一点 yield 。标签。

个人?我更喜欢将文字包裹起来

如果您有能力使用 jQuery to wrap all unwrapped text in p tags,那么就会有这个 SO 答案

关于css - 在 HTML5 中为 "just text"使用 p 标签是否有充分的理由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23617794/

上一篇:html - SVG 路径在 IE10+ 中没有大小,不显示标签位置

下一篇:html - 是否可以在分层绝对 div 上进行 2 个 CSS3 不透明度转换,每个 div 1 个?

相关文章:

html - 如何将文本框对齐在同一行?

HTML5 和多个 ARIA 角色

javascript - 为什么带 # 的链接在 Firefox 和 Safari 中不起作用?

javascript - 如何更改 JavaScript 中的最后一个文本节点子节点

html - 如何垂直对齐 td 内的 float 表格

jquery - 如何在单击图像链接时更改 Div 的内容?

php - javascript错误控制台说xml不能是整个程序

css - 我可以为 css 声明哪些通用 html5 根元素?

java - 如何在 Java 中创建文章旋转器正则表达式?

css - 如果 textarea 的父项都没有固定大小,为什么它不接受相对字体大小? (火狐 18.0 Mac)