The Wayback Machine - https://web.archive.org/web/20240621040859/https://www.geeksforgeeks.org/html5-semantics/
Open In App

HTML5 Semantics

Last Updated : 18 Jun, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML5 Semantics refers to the use of specific tags like <header>, <footer>, <nav>, <article>, <section>, etc., to provide clearer structure and meaning to web content. This improves accessibility, and SEO, and facilitates better understanding by both humans and machines.

Why Do I Need to Use Semantic HTML Tags?

Using semantic HTML tags enhances website accessibility, improves search engine optimization (SEO), and provides clearer structure and meaning to content. This fosters better understanding by both users and machines, leading to improved usability and user experience.

HTML tags are classified into two types: 

  • Semantic
  • Non-Semantic

Semantic Elements

Semantic elements have meaningful names that tell about the type of content. For example header, footer, table, … etc. HTML5 introduces many semantic elements as mentioned below which make the code easier to write and understand for the developer as well as instruct the browser on how to treat them. 

HTML5-Semantics-copy

The article Tag

It contains independent content which doesn’t require any other context blog Post, Newspaper Article, etc.

Example: The below example shows the implementation of the article Tag.

html
<!DOCTYPE html>
<html>

<head>
    <title>Article Tag</title>
    <style>
        h1 {
        Color:#006400;
        font-size:50px;
        Text-align:left;
        }
        p {
        font-size:25px;
        text-align:left;
        margin-top:-40px;
        }
    </style>
</head>

<body>
    <article>
        <h1>GeeksforGeeks</h1>
        <p>A Computer Science Portal for Geeks</p>
    </article>
</body>

</html>

Output: 

Article tag


Aside

It is used to place content in a sidebar i.e. aside from the existing content. It is related to surrounding content.

Example: The below example shows the implementation of the aside Tag.

html
<!DOCTYPE html>
<html>

<head>
    <title>Aside Tag</title>
    <style>
        h4 {
        Color:#006400;
        font-size:50px;
        Text-align:none;
        margin-bottom:0px;
        }
        p {
        font-size:25px;
        text-align:none;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <p>GeeksforGeeks is a Computer Science Portal</p>
    <aside>
        <h4>GeeksForGeeks</h4>
        <p>GeeksforGeeks is a computer Science platform
            where you can learn good programming.
        </p>
    </aside>
</body>

</html>

Output:

aside tag

Details and Summary

The “details” defines additional details that the user can hide or view. “summary” defines a visible heading for a “details” element.

Example: The below example shows the implementation of the Details and Summary.

html
<!DOCTYPE html>
<html>

<head>
    <title>Detail and summary Tag</title>
    <style>
        .GFG {
        Color:#006400;
        font-size:50px;
        Text-align:none;
        margin-bottom:0px;
        }
        p {
        font-size:25px;
        text-align:none;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <details>
        <summary class="GFG">
            GeeksforGeeks
        </summary>
        <p>GeeksforGeeks is a Computer Science portal
            where you can learn good programming.
        </p>
    </details>
</body>

</html>

Output:

summary

Figure and Figcaption

These are used to add an image to a web page with a small description.

Example: The below example shows the implementation of Figure and Figcaption.

html
<!DOCTYPE html>
<html>

<head>
    <title>Figcaption Tag</title>
    <style>
        h2 {
        Color:#006400;
        font-size:50px;
        Text-align:none;
        margin-bottom:0px;
        }
        p {
        font-size:25px;
        text-align:none;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <h2>GeeksforGeeks</h2>
    <figure>
        <img src="4.jpg" 
             alt="gfg" 
             style="width:20%">
        <figcaption>
          GeeksforGeeks Logo
          </figcaption>
    </figure>
</body>

</html>

Output:

figcaption

Header

As the name suggests, it is for the header of a section introductory of a page. There can be multiple headers on a page.  

Example: The below example shows the implementation of the Header.

html
<!DOCTYPE html>
<html>

<head>
    <title>Header Tag</title>
    <style>
        h1, h3 {
        Color:#006400;
        Text-align:left;
        margin-bottom:0px;
        }
        p {
        font-size:25px;
        text-align:left;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <article>
        <header>
            <h1>GeeksforGeeks</h1>
            <h3>GeeksforGeeks</h3>
            <p>A computer Science portal</p>
        </header>
    </article>
</body>

</html>

Output:

header tag

Footer

Footer located at the bottom of any article or document, they can contain contact details, copyright information etc. There can be multiple footers on a page. 

Example: The below example shows the implementation of the Footer.

html
<!DOCTYPE html>
<html>

<head>
    <title>footer Tag</title>
    <style>
        p {
        font-size:25px;
        text-align:left;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <footer>
        <p>
            Posted by: GeeksforGeeks
        </p>

        <p>
            Contact: 
            <a href=
"https://www.geeksforgeeks.org">
                geeksforgeeks.org
            </a>.
        </p>
    </footer>
</body>

</html>

Output:

footer tag

Main

It defines the main content of the document. The content inside the main tag should be unique. 

Example: The below example shows the implementation of the Main in HTML.

html
<!DOCTYPE html>
<html>

<head>
    <title>main Tag</title>
    <style>
        h1 {
        color:#006400;
        }
        p {
        font-size:25px;
        text-align:none;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <main>
        <h1>Important Residences</h1>
        <p>
            A few of them are 
            Rashtrapati Bhavan, 
            White House etc
        </p>

        <article>
            <h1>Rashtrapati Bhavan</h1>
            <p>
                It is the home of 
                the President of India.
            </p>
        </article>
        
        <article>
            <h1>The White House</h1>
            <p>
                It is the home of the 
                President of United
                States of America.
            </p>
        </article>
    </main>
</body>

</html>

Output:

main tag

Section

A page can be split into sections like Introduction, Contact Information, Details, etc and each of these sections can be in a different section tag.

Example: The below example shows the implementation of the section Tag.

html
<!DOCTYPE html>
<html>

<head>
    <title>section Tag</title>
    <style>
        h1 {
        color:#006400;
        }
        p {
        font-size:25px;
        text-align:none;
        margin-top:0px;
        }
    </style>
</head>

<body>
    <section>
        <h1>Data Structure</h1>
        <p>
            Data Structure is a data
            organization and storage
            format that enables efficient
            access and modification.
        </p>
    </section>
    <section>
        <h1>Algorithm</h1>
        <p>
            A process or set of rules to
            be followed in calculations
            or other problem-solving
            operations, especially by
            a computer.
        </p>
    </section>
</body>

</html>

Output:

section tag

The nav Tag

It is used to define a set of navigation links in the form of a navigation bar or nav menu. 

Example: The below example shows the implementation of the nav tag.

html
<!DOCTYPE html>
<html>

<head>
    <title>nav Tag</title>
    <style>
        h1 {
        color:#006400;
        }
    </style>
</head>

<body>
    <h1>Navigation Bar</h1>
    <nav>
        <a href="/home/">
            Home
        </a> |
        <a href="/about-us/">
            About Us
        </a> |
        <a href="/data-structure/">
            Data Structure
        </a> |
        <a href="/operating-system/">
            Operating System
        </a>
    </nav>
</body>

</html>

Output: 

nav tag

Mark

It is used to highlight the text.

Example: The below example shows the implementation of the Mark in HTML.

html
<!DOCTYPE html>
<html>

<head>
    <title>mark Tag</title>
    <style>
        h1 {
        color:#006400;
        }
    </style>
</head>

<body>
    <h1>mark tag</h1>
    <p>
        GeeksforGeeks is a
        <mark>Computer Science</mark>
        portal
    </p>
</body>

</html>

Output:

mark tag

Non-Semantic Elements

Tags like div, and span fall under the Non-Semantic categories as their names don’t tell anything about what kind of content is present inside them.

div It is a block-level element or division of a section. It is used as a container.

Example: The below example shows the implementation of Non-Semantic Elements.

html
<!DOCTYPE html>
<html>

<head>
    <title>div Tag</title>
    <style>
        .GFG {
        color:#006400;
        }
    </style>
</head>

<body>
    <h1>div Tag</h1>
    <div class="GFG">
        <h1>GeeksforGeeks</h1>
        <p>GeeksforGeeks is a Computer Science portal</p>
    </div>
</body>

</html>

Output:

div tag

span: It is an inline element that doesn’t start on a new line and takes up only the necessary width. For more details use https://www.geeksforgeeks.org/span-tag-html/.

Supported Browsers

  • Google Chrome: 1
  • Edge: 12
  • Mozilla: 1
  • Opera: 15
  • Safari: 4


Previous Article
Next Article

Similar Reads

HTML5 MathML &lt;semantics&gt; Tag
The HTML5 MathML &lt;semantics&gt; tag is an inbuilt element in HTML 5. It is used to markup mathematics there are two possible ways to markup mathematics. Presentation MathML is used to control the layout of any mathematical equations.Content MathML is designed to encode the semantic mathematical meaning and make expressions understandable to comp
2 min read
Mutable and Immutable useRef Semantics with React JS
The useRef hook in React.js is essential for preserving references to DOM nodes or persistent values across renders. It accommodates both mutable and immutable values, influencing React's re-rendering behavior based on whether changes are made to mutable or immutable properties of the useRef hook. Table of Content Immutable Current PropertyMutable
3 min read
How to set a name for keygen element in HTML5 ?
In HTML, the &lt;keygen&gt; tag is used to specify a key-pair generator field during a form, and the &lt;keygen&gt; name attribute is used to set the name of the keygen element. The aim of &lt;keygen&gt; element is to supply a secure thanks to authenticate users. When a form is submitted then two keys are generated, the private key and the public k
2 min read
How to define the URL of an external script file in HTML5 ?
In this article, we will learn how to define the URL of an external script file inside HTML. This may be needed when a large script code is needed to be included, and it may create confusion if all the code is written in a single file. Also, there may be a requirement for the same script to execute on different web pages, and rewriting the same cod
1 min read
How to change the font of HTML5 Canvas using a button in Angular.js?
In this article, we are going to learn about how to change the font of HTML5 Canvas using a button in AngularJS. With the help of a click font's property can change by the user whether it is font-size or font-style. Syntax: For font size (Change the font size accordingly): variable.fontSize = "100px" For font style (Change the font style accordingl
2 min read
How to display video controls in HTML5 ?
The HTML &lt;video&gt; controls attribute is used to display video controls in HTML5. It is the Boolean value. HTML5 most commonly uses ogg, mp4, ogm and ogv as a video formats in the video tag because the browser support for them differs. Syntax &lt;video controls&gt; &lt;source&gt; &lt;/video&gt; From above Syntax controls attribute adds video co
2 min read
How to define a client-side script in HTML5 ?
To define a client-side script in HTML5, we can do &lt;script&gt; tag or adding external script file by src attribute to the HTML file. &lt;script&gt; tag contains the JavaScript to be added for the client-side scripting. Syntax: &lt;script&gt; // JavaScript goes here console.log('GeeksforGeeks'); &lt;/script&gt; Below are the examples for the abov
1 min read
HTML5 Game Development | Infinitely Scrolling Background
Game Design and Development is an emerging industry. Although making AAA titles will require advanced knowledge of game engines, DirectX, OpenGL, etc. small HTML5 video game projects is a good place to start. HTML5 canvas and javascript can be used to make small games while learning the fundamentals of game development like Collision-Detection, Obj
5 min read
HTML5 | Mathematical operators
Mathematical Operators are used for representation of mathematical and technical operators. In HTML5 some special codes are used. For the representation of these operators we can use the name or hexadecimal(Hex) reference. Examples: Input : &amp;minus or &amp;#8722 Output : - Input : &amp;times or &amp;#215 Output : x Input : &amp;frac34 or &amp;#1
1 min read
HTML5 MathML &lt;menclose&gt; Tag
The HTML5 MathML &lt;menclose&gt; tag tag is an inbuilt element in HTML5. It is used to renders the contents which is inside of anbenclosing notation specified by the notation attribute. Syntax: &lt;menclose attribute="value "&gt; child elements &lt;/menclose"&gt;Attributes: The tag accepts some attributes which are listed below: class| id| style:
2 min read
Article Tags :