# 5.5 定值布尔属性

HTML有布尔属性的概念。布尔属性没有值，属性存在意味着值是“true”。在XHTML里，这些属性只有一个值，这个值就是它自己。 例如，`checked`：

```markup
<input type="checkbox" name="option2" checked /> <!-- HTML -->
<input type="checkbox" name="option1" checked="checked" /> <!-- XHTML -->
```

标准方言包含允许你通过求值条件设置属性的属性。如果求值为true，属性将会被设置为它的定值。如果为false，属性将不会被设置：

```markup
<input type="checkbox" name="active" th:checked="${user.active}" />
```

以下定值布尔属性存在标准方言里：

|                   |              |               |
| ----------------- | ------------ | ------------- |
| th:async          | th:autofocus | th:autoplay   |
| th:checked        | th:controls  | th:declare    |
| th:default        | th:defer     | th:disabled   |
| th:formnovalidate | th:hidden    | th:ismap      |
| th:loop           | th:multiple  | th:novalidate |
| th:nowrap         | th:open      | th:pubdate    |
| th:readonly       | th:required  | th:reversed   |


---

# 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/5-setting-attribute-values/5.5-fixed-value-boolean-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.
