×

注意!页面内容来自https://www.geeksforgeeks.org/html/html5-introduction/,本站不储存任何内容,为了更好的阅读体验进行在线解析,若有广告出现,请及时反馈。若您觉得侵犯了您的利益,请通知我们进行删除,然后访问 原网页

<> #nprogress { pointer-events: none; } #nprogress .bar { background: #29D; position: fixed; z-index: 9999; top: 0; left: 0; width: 100%; height: 3px; } #nprogress .peg { display: block; position: absolute; right: 0px; width: 100px; height: 100%; box-shadow: 0 0 10px #29D0 0 5px #29D; opacity: 1; -webkit-transform: rotate(3deg) translate(0px-4px); -ms-transform: rotate(3deg) translate(0px-4px); transform: rotate(3deg) translate(0px-4px); } #nprogress .spinner { display: block; position: fixed; z-index: 1031; top: 15px; right: 15px; } #nprogress .spinner-icon { width: 18px; height: 18px; box-sizing: border-box; border: solid 2px transparent; border-top-color: #29D; border-left-color: #29D; border-radius: 50%; -webkit-animation: nprogresss-spinner 400ms linear infinite; animation: nprogress-spinner 400ms linear infinite; } .nprogress-custom-parent { overflow: hidden; position: relative; } .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar { position: absolute; } @-webkit-keyframes nprogress-spinner { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes nprogress-spinner { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
  • Courses
  • Tutorials
  • Interview Prep

HTML5 Introduction

Last Updated : 13 Dec2025

HTML5 is the fifth version of Hypertext Markup Language (HTML)a standard language used to structure webpages. It defines how content on a webpage should be structured and displayed. Here are some key points of HTML5.

  • Provides multimedia support by embedding audio and video without plugins.
  • Adds new form controls like date and email input types.
  • Enables web storage to store data offline for better performance.
  • Uses semantic elements such as <header> and <footer> for clearer structure.
  • Delivers improved performanceespecially on mobile devices.
HTML
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-widthinitial-scale=1.0">
    <title>Simple HTML Page</title>

</head>
<body>

    <header>
        <h1>HelloWorld!</h1>
    </header>

    <main>
        <p>This is a simple HTML5 page.</p>
    </main>

    <footer>
        <p>@GeeksforGeeksSanchhaya Education Private LimitedAll rights reserved</p>
    </footer>

</body>
</html>
  • It defines a simple HTML5 page with DOCTYPE<html><head>and <body> tags.
  • Includes a character set (UTF-8) and viewport settings for mobile responsiveness.
  • Contains a headermain contentand footer with basic text content.

New Added Elements in HTML 5

HTML5 introduced several new elements that help structure a webpage better and make it more interactive. These elements not only improve the design but also make the code more readable and accessible. Here are some key elements of HTML5:

  • <article>: The <article> tag represents independentself-contained content like articles or posts.
  • <aside>: The <aside> tag holds secondary or related information supporting the main content.
  • <figcaption>: The <figcaption> tag provides a caption or description for a <figure> element.
  • <figure>: The <figure> tag groups self-contained media such as imagesdiagramsor code.
  • <header>: The <header> tag contains introductory content like headings or navigation links.
  • <footer>: The <footer> tag includes closing content such as author info or copyright notes.
  • <main>: The <main> tag defines the centralmost important content of the webpage.
  • <mark>: The <mark> tag highlights or emphasizes specific text.
  • <nav>: The <nav> tag groups navigation links for moving around the site.
  • <section>: The <section> tag organizes related content into thematic blocks.
  • <details>: The <details> tag creates expandable or collapsible content sections.
  • <summary>: The <summary> tag provides the clickable heading for a <details> element.
  • <time>: The <time> tag represents dates or times in a readable and machine-usable format.
  • <bdi>: The <bdi> tag isolates text with unknown or mixed text direction.
  • <wbr>: The <wbr> tag adds an optional line-break position in long words.
  • <datalist>: The <datalist> tag provides autocomplete suggestions for an <input> element.
  • <keygen>: The <keygen> tag generates key pairs for secure authentication (deprecated).
  • <output>: The <output> tag displays results of calculations or script actions.
  • <progress>: The <progress> tag visually represents the progress of a task.
  • <svg>: The <svg> tag embeds scalable vector graphics into a webpage.
  • <canvas>: The <canvas> tag draws dynamic graphics using JavaScript.
  • <audio>: The <audio> tag embeds audio content like music or sound effects.
  • <embed>: The <embed> tag inserts external resources such as media players or apps.
  • <source>: The <source> tag defines media sources for <audio> and <video> elements.
  • <track>:The <track> tag provides captions or subtitles for videos.
  • <video>: The <video> tag embeds video content directly into a webpage.

Deprecated Elements in HTML5

HTML5 has removed several outdated elementsreplacing them with newermore flexible solutions:

  • The <acronym> tag is removed; use <abbr>.
  • The <applet> tag is outdated; use <object>.
  • The <basefont> tag is removed; use CSS for font styling.
  • The <big> tag is removed; use CSS font-size.
  • The <center> tag is not supported; use CSS text-align.
  • The <dir> tag is removed; use <ul>.
  • The <font> tag is removed; use CSS for all text styling.
  • The <frame><frameset>and <noframes> tags are removed with no replacements.
  • The <isindex> tag is removed and no longer needed.
  • The <strike> tag is removed; use CSS<s>or <del>.
  • The <tt> tag is removed; use CSS or <code> for monospace text.

HTML5 Advantages

HTML5 offers several benefits that enhance modern web development like:

  • Works on all major browsers and devices (cross-platform).
  • Lets websites access user location (geolocation).
  • Supports offline use through Web Storage or AppCache.
  • Uses semantic tags for cleanersimpler code.
  • Optimized for smooth performance on mobile devices.

HTML5 Disadvantages

Despite its strengthsHTML5 comes with some drawbacks:

  • Older browsers may not support all HTML5 features (browser inconsistencies).
  • Some older mobile devices struggle with HTML5 (mobile compatibility issues).
  • Web Storage and similar features can pose security risks if misused.
  • Advanced APIs introduce complexity for beginners.
  • IE 8 and below show poor support for HTML5.

Example of HTML5

Here are demonstration of some HTM5 elements:

Adding a Video Using the <video> Tag

HTML
<html>
<body>
    <video width="320" height="100" controls>
        <source src="movie.mp4" type="video/mp4">
        Your browser does not support the video tag.
    </video>
</body>
</html>
  • The <video> tag is used to embed a video in the HTML page.
  • The controls attribute adds playpauseand volume control buttons.
  • The <source> tag specifies the video file and format. If the video is not supportedthe text inside the <video> tag will be displayed.

Using the <canvas> Element for Drawing

HTML
<html>
<body>
    <canvas id="myCanvas" width="100" height="100"></canvas>
    <script>
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        ctx.fillStyle = "blue";
        ctx.fillRect(50, 50, 100, 100);
    </script>
</body>
</html>
  • The <canvas> tag is used to create an area for drawing graphics using JavaScript.
  • The getContext(“2d”) method is used to set up a 2D drawing context on the canvas.
  • The fillRect method draws a blue rectangle within the canvas.

Using the <progress> Element to Show Task Progress

HTML
<html>
<body>
    <h1>HTML5 Progress Bar Example</h1>
    <progress value="70" max="100"></progress>
</body>
</html>
  • The <progress> tag is used to display a progress bar on the webpage.
  • The value attribute sets the current progressand the max attribute defines the maximum value.

Best Practices of Using HTML5

  • Use Semantic Tags: Improve SEO and accessibility by using tags like <header><footer><article>and <section>.
  • Ensure Cross-Browser Compatibility: Test your code across multiple browsersespecially older versions.
  • Use <meta charset=”UTF-8″>: Always specify the character encoding at the start to avoid encoding issues.
  • Mobile Responsiveness: Use the <meta name=”viewport” content=”width=device-widthinitial-scale=1.0″> tag for mobile-friendly designs.
Comment