/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: open

[this page | pdf | back links]

The HTML open attribute indicates whether details in a <details> or <dialog> element should be visible (i.e. open) to the user.

 

Valid attribute values (for <details>) include:

 

Value

Description

open

Specifies whether the details should be visible to user

 

Valid attribute values (for <dialog>) include:

 

Value

Description

open

Specifies whether the dialog element is active and hence whether the user can interact with it

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<details open>these details are immediately visible to users</details><br>
<details>these details need further action to become visible</details>

<br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.getElementById("element");
var x1 = document.createElement("DETAILS");
x1.textContent = "these details are immediately visible to users";
x1.setAttribute("open","open");
var br1 = document.createElement("BR");
var x2 = document.createElement("DETAILS");
x2.textContent = "these details need further action to become visible";
x.appendChild(x1);
x.appendChild(br1);
x.appendChild(x2);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile