<s>
和<del>
之间的区别?我在这里读到(https://dev59.com/2XVC5IYBdhLWcg3whBWj#271776)<b>
和<strong>
之间存在语义差异,那么<s>
和<del>
是否也适用?此外,搜索引擎如何解释这样的语义差异(如果有的话),并对排名产生什么影响?还有其他标签会影响搜索排名吗?<s>
和<del>
之间的区别?我在这里读到(https://dev59.com/2XVC5IYBdhLWcg3whBWj#271776)<b>
和<strong>
之间存在语义差异,那么<s>
和<del>
是否也适用?此外,搜索引擎如何解释这样的语义差异(如果有的话),并对排名产生什么影响?还有其他标签会影响搜索排名吗?<s>
元素参考的一个重要部分,该参考指出:“s 元素表示不再准确或不再相关并已从文档中删除的内容。” 在这方面,<s>
和 <del>
当然是完全相同的吧? - Sprogz<s>
感觉太像简单的排版标记,比如<b>
。因此,出于这个原因,我更倾向于使用<del>
。 - gfullam<s>
所说的与这个回答引用的旧版草案中完全一样,没有提到任何东西被“删除”。唯一的例子是关于老零售价格被提及以及新价格。将旧价格称为“不再准确或不再相关”是荒谬的,因为它是专门为了比较而提到的——它是准确的(作为过去事实)并且相关。这表明这些“语义”定义和区分存在问题。 - Jukka K. KorpelaDEL
的示例(https://html.spec.whatwg.org/multipage/edits.html#the-del-element)甚至不是通常的差异样本,而是使用`S`直观地完成待办事项清单的“已完成”项目(这绝对不是通过任何方式“从文档中删除”,直到它被实际删除为止...)。 - Sz.<strike>
It's clear that <strike>
is deprecated, and therefore not correct to use anymore.
<s>
From <s>
on MDN:
The HTML Strikethrough Element (
<s>
) renders text with a strikethrough, or a line through it. Use the<s>
element to represent things that are no longer relevant or no longer accurate. However,<s>
is not appropriate when indicating document edits; for that, use the<del>
and<ins>
elements, as appropriate.**
<del>
From <del> on MDN
:
The HTML Deleted Text Element (
<del>
) represents a range of text that has been deleted from a document. This element is often (but need not be) rendered with strike-through text.
The biggest key to me on this page is that <del>
, like <ins>
, offers two additional (optional) attributes: cite
and datetime
which make sense in referring to a change in the context of a document. As a counterexample, if I were updating a restaurant menu, citing a source for a menu item being sold out doesn't seem relevant.
No tag / use CSS
If none of the above seem correct for your use case, remember that you can still define a custom class.
.purchased { text-decoration: line-through; }
<p>Wish list</p>
<ul>
<li class="purchased">New MacBook</li>
<li>Cookies</li>
</ul>
del
和s
之间没有实际区别。它们具有相同的默认呈现效果(删除线文本),并且没有证据表明浏览器或搜索引擎在处理这些元素时有任何差异,也没有理由期望出现这样的差异,因为“语义”定义是模糊的,作者对此并不太关心。任何搜索引擎上这些元素都没有被处理——它们处理的是文本,并通常忽略文本级标记,除非一些元素可能被视为使其内容在页面中具有更大的相对权重。del、s、strike { text-decoration:line-through; }
理论上的区别在于HTML规范和草案对它们的“含义”所说的话,在不同的HTML版本中有所不同。strike
可能是最安全的选择,它是一个诚实的表现元素。这样您甚至避免了一些软件可能会基于某人对HTML5 CR的阅读而以某种特殊的方式解释s
或del
,从而可能导致一些呈现或处理与您打删除线的原因不一致。(历史上,s
和strike
是同义词,但HTML5 CR在它们之间划分出任意区别,将s
称为“语义”元素,将strike
称为表现元素。)S
表示旧价格标签,但用'DEL'表示旧的(已完成)待办事项……)。 (注意:显然,有些情况下选择是明确的,例如用于呈现差异输出的DEL
等)。 - Sz.