The open attribute is a small instruction attached to an HTML element. Its job is to start details or dialog in an open state. It is easier to remember when you can see it in a real piece of markup.
What open is used for
Start details or dialog in an open state. The attribute appears inside an element’s opening tag. Depending on its definition, it may take a specific string, a number, an enumerated keyword, or be a boolean attribute.
The example below uses it in a details context. Other elements may support it too, or may give the same attribute a different meaning.
Example you can try
<details open>
<summary>How to register</summary>
<p>Fill out the form before Friday.</p>
</details>
How the example works
Look for open in the snippet. Here the example shows its presence without a string value. This is a concrete input the browser can interpret; it is not just text shown to the reader.
The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.
Values and important behavior
On details and dialog, this is a boolean state attribute; opening a modal dialog correctly usually uses showModal().
This detail matters most when the page receives user input, navigates to another document, or loads an external resource. In those cases, check the browser behavior and any server-side requirements separately.
Small practice task
Copy the code and change open to another sensible value, or remove it entirely if it is optional. Test the difference in the browser and inspect any submitted value or network request.
Common Beginner Mistakes
- The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.
- Using
openon an element that does not support it. - Believing that an HTML hint or client-side check replaces real server validation or a security policy.
Key Takeaways
openis used to start details or dialog in an open state.- The effect depends on the element and the browser. Make sure the value matches what the chosen element supports.
- Choose valid values and test the result instead of guessing what the browser will do.