# 转义的元素属性

为了避免与可能在其它模式下被处理的模版某部分的交互（比如，在`HTML`模版里的`文本`模式内联），Thymeleaf 3.0允许元素里的属性用它的文本语法转义。

* `TEXT`模版模式里的属性将会HTML转义。.
* `JAVASCRIPT`模版模式里的属性将会JavaScript转义。
* `CSS`模版模式里的属性将会CSS转义。

所以，在`TEXT`模式的模版里，下面的代码完全OK（注意`&gt;`）：

```
  [# th:if="${120&lt;user.age}"]
     Congratulations!
  [/]
```

当然这个`&lt;`在真实的文本模版里毫无意义，但是如果我们正在处理一个HTML模版。它里面的`th:inline="text"`块包含了上面的代码。而且，我们想要：在静态地打开文件时，确保浏览器不会把那个`<user.age`当成是一个开始标签的名字。这种情况下，这就是一个好主意。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/13-wen-ben-mo-ban-mo-shi/13.1-textual-syntax/escaped-element-attributes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
