Advanced Semantic and Interactive Elements
HTML5 includes elements that make documents more interactive and expressive without immediately reaching for JavaScript-heavy solutions.
<details> and <summary>
Purpose:
- create expandable and collapsible sections
Important attributes:
openon<details>
Example:
<details>
<summary>What is semantic HTML?</summary>
<p>Semantic HTML uses tags that describe meaning, such as article, nav, and footer.</p>
</details>
<dialog>
Purpose:
- represents a dialog box or modal window
Important attributes:
open
Example:
<dialog open>
<p>This is a dialog window.</p>
<button>Close</button>
</dialog>
<progress>
Purpose:
- shows task progress
Important attributes:
valuemax
Example:
<progress value="60" max="100">60%</progress>
<meter>
Purpose:
- shows a measurement inside a known range
Important attributes:
valueminmaxlowhighoptimum
<template>
Purpose:
- stores markup that is not rendered immediately
It is useful when JavaScript will later clone or insert repeated content.
Why These Elements Matter
They give built-in meaning and behavior, which often leads to:
- cleaner code
- better accessibility
- less custom scripting