HTML open Attribute

Description

The open attribute in HTML is a Boolean attribute used primarily with the <details> element to indicate that the contents should be visible by default. When a <details> element includes the open attribute, it means that the detailed information contained within it, usually wrapped by a <summary> tag for the title or heading, is displayed to the user from the start. Without the open attribute, the content is hidden and only shown when the user activates the <summary> element, typically by clicking on it.

In essence, the open attribute controls the initial display state of the additional information that <details> encompasses. Its presence (with or without a value, since it's a Boolean attribute) means the details are expanded, and its absence means they are collapsed. This attribute enhances web pages by allowing for the efficient organization of content, making it more user-friendly by showing or hiding details as needed or as preferred by the web designer.

Syntax

<details open>

Values

The open attribute is a boolean attribute, therefore no values are associated with this attribute.

Applies To

The open attribute can be used on the following html elements.

Example

<details open>
<summary>This is a summary</summary>
<p>Here are some details that will be visible by default because the open attribute is present.</p>
</details>

<details>
<summary>This is another summary</summary>
<p>Here are some details that will be hidden by default because the open attribute is not present.</p>
</details>

Browser Support

The following table will show you the current browser support for the HTML open Attribute.

Desktop
Edge Chrome Firefox Opera Safari
791249156
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184914614.4

Last updated by CSSPortal on: 29th March 2024