使用 <strike> 标签

问题描述 投票:0回答:1

我需要使用 html 标签删除整个表格行。我在 tr 周围应用了 ,但它不起作用。请建议我如何实现这一目标。

我尝试使用 css line through 的其他选项如下所示。这是可行的,但我相信辅助技术不会识别该线路。因此,本论坛中针对此问题回答的其他答案在这种情况下不起作用。

<tr style="text-decoration: line-through; color:red; width:100%">

我已附上示例代码。我希望第 2 行被删除。任何方法都可以实现这一目标。

<!DOCTYPE html>
<html>

<head>

<table style="border: 1px solid black;width:100%">
    <thead>
      <tr>
        <th>Table 1 Head 1</th>
        <th>Table 1 Head 2</th>
        <th>Table 1 Head 3</th>
        <th>Table 1 Head 4</th>
      </tr>
    </thead>

    <tr>
      <td>Row 1 Column 1</td>
      <td>Row 1 Column 2</td>
      <td>Row 1 Column 3</td>
      <td>Row 1 Column 4</td>
    </tr>
    <strike>
    <tr>
          <td>Row 2 Column 1</td>
          <td>Row 2 Column 2</td>
          <td>Row 2 Column 3
          </td>
          <td>Row 2 Column 4</td>
        </tr>
        </strike>
        <tr>
          <td>Row 3 Column 1</td>
          <td>Row 3 Column 2</td>
          <td>Row 3 Column 3</td>
          <td>Row 3 Column 4</td>
        </tr>
  </table>
  </body>
  </html>
  

html accessibility
1个回答
1
投票

如果你想在语义上有意义,你需要在每个

<strike>
中放置一组<td>标签
inside
,你不能一次完成整行。

也就是说,如果您想要语义,请使用

<s>
<del>
标签而不是
<strike>
。来自MDN

警告:此元素在 HTML 4 和 XHTML 1 中已弃用,并在 HTML Living Standard 中已废弃。如果语义上合适,即如果它代表已删除的内容,请改用

<del>
。在所有其他情况下,请使用
<s>

<s>
<del>
<strike>
一样 - 您不能将它们放在整个表格行周围。这些标签内允许的唯一内容是“短语内容”,包括纯文本和某些内联内容元素(在上面的链接中列出)。此列表包括表格元素。

© www.soinside.com 2019 - 2024. All rights reserved.