> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/thymeleaf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/11-zhu-shi-yu-kuai/11.4.-synthetic-th-block-tag.md).

# 11.4. 人造th:block标签

`th:block`是Thymeleaf唯一的元素处理器（不是属性），包含在标准方言里。

`th:block`是一个纯粹的属性容器。它允许模版开发者指定任何他们想要的属性。Thymeleaf将执行这些属性，然后简单地使块（不是内容）消失。

所以，它会很有用。比如，当创建遍历的表格时，每一个元素需要多个`<tr>`：

```markup
<table>
  <th:block th:each="user : ${users}">
    <tr>
        <td th:text="${user.login}">...</td>
        <td th:text="${user.name}">...</td>
    </tr>
    <tr>
        <td colspan="2" th:text="${user.address}">...</td>
    </tr>
  </th:block>
</table>
```

当结合原型注释块时，特别有用：

```markup
<table>
    <!--/*/ <th:block th:each="user : ${users}"> /*/-->
    <tr>
        <td th:text="${user.login}">...</td>
        <td th:text="${user.name}">...</td>
    </tr>
    <tr>
        <td colspan="2" th:text="${user.address}">...</td>
    </tr>
    <!--/*/ </th:block> /*/-->
</table>
```

注意：这种方案允许模版成为有效的HTML（不需要在 `<table>`里添加禁止的 `<div>`块）。当作为原型在浏览器里静态地打开时，仍然正常工作！
