<details>
and <summary>
:
These elements create a disclosure widget that users can open and close. <details>
is the container, and <summary>
is the visible heading that users click to expand or collapse the content.
<details>
<summary>More Information</summary>
<p>This content is hidden until the user clicks "More Information".</p>
</details>
<datalist>
:
This element provides an autocomplete feature for input elements. It defines a list of predefined options for an <input>
element.
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Safari">
<option value="Edge">
</datalist>
<output>
:
This element represents the result of a calculation or user action. It’s often used with JavaScript to display dynamic values.
<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50"> +
<input type="number" id="b" value="100">
= <output name="result" for="a b">150</output>
</form>
<progress>
:
This element displays the progress of a task. It shows a progress bar indicating the completion percentage.
<progress value="70" max="100">70%</progress>
<meter>
:
This element represents a scalar measurement within a known range, or a fractional value. It’s useful for displaying values such as disk usage or battery life.
<meter value="0.7" min="0" max="1">70%</meter>
<template>
:
This element holds client-side content that won’t be rendered when the page loads but can be instantiated later using JavaScript. It’s useful for storing reusable content fragments.
<template id="my-template">
<div class="my-content">
<h2>Template Content</h2>
<p>This content can be cloned and inserted into the DOM.</p>
</div>
</template>
- Custom Data Attributes (
data-*
):
These attributes allow you to store extra information on HTML elements without using non-standard attributes or DOM properties. They can be accessed using JavaScript.
<div data-user-id="12345" data-role="admin">User Info</div>
<script>
const userInfo = document.querySelector('[data-user-id]');
console.log(userInfo.dataset.userId); // Output: 12345
console.log(userInfo.dataset.role); // Output: admin
</script>
Like this:
Like Loading...
Related