HTML5, which stands for HyperText Markup Language 5, is the latest version of the HTML standard used for creating and structuring content on the web. HTML is a markup language that defines the structure of a web page using elements and tags. HTML5 introduced several new features and improvements over its predecessor, HTML4, to enhance the capabilities of web development.

Here are some key features of HTML5, along with examples:

  1. DOCTYPE Declaration: HTML5 uses a simplified and shorter DOCTYPE declaration.

    html
    <!DOCTYPE html>
  2. New Structure Elements: HTML5 introduced new semantic elements to better define the structure of a web page.

    html
    <header> <h1>Website Title</h1> </header> <nav> <ul> <li><a href="#home">Home</a></li> <li><a href="#about">About</a></li> <li><a href="#contact">Contact</a></li> </ul> </nav> <section> <article> <h2>Article Title</h2> <p>Article content goes here.</p> </article> <article> <h2>Another Article Title</h2> <p>More content for another article.</p> </article> </section> <footer> <p>&copy; 2023 Your Website</p> </footer>
  3. Audio and Video Elements: HTML5 introduced native support for embedding audio and video content.

    html
    <audio controls> <source src="audio.mp3" type="audio/mp3"> Your browser does not support the audio tag. </audio> <video width="320" height="240" controls> <source src="video.mp4" type="video/mp4"> Your browser does not support the video tag. </video>
  4. Canvas: The <canvas> element allows for dynamic rendering of graphics, animations, and other visual content.

    html
    <canvas id="myCanvas" width="200" height="100"></canvas> <script> var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext("2d"); ctx.fillStyle = "lightblue"; ctx.fillRect(0, 0, 200, 100); </script>
  5. Local Storage: HTML5 introduced the localStorage object for storing data locally in the user's browser.

    html
    <script> // Store data localStorage.setItem("username", "John"); // Retrieve data var username = localStorage.getItem("username"); console.log("Username: " + username); </script>

These examples showcase some of the new features and improvements introduced with HTML5. Keep in mind that HTML is often used in conjunction with CSS (Cascading Style Sheets) for styling and JavaScript for interactivity to create fully functional web pages.