HTML Tags
Advertisements

HTML5 <main> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <main> element represents the main or dominant content of the <body> of a document.

The following table summarizes the usages context and the version history of this tag.

Placement: Block
Content: Block, inline, and text
Start/End Tag: Start tag: required, End tag: required
Version: New in HTML5

Syntax

The basic syntax of the <main> tag is given with:

HTML / XHTML: <main> ... </main>

The example below shows the <main> tag in action.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <title>HTML main Tag</title>
</head>
<body>
    <header>
        <h1>Welcome to our website</h1>
    </header>

    <main>
        <h1>Core Web Technologies</h1>
        <p>HTML and CSS are two of the core technologies for building web pages.</p>
        <article>
            <h2>What is HTML?</h2>
            <p>HTML stands for HyperText Markup Language. HTML is the standard markup language for describing the structure of web pages.</p>
        </article>
        <article>
            <h2>What is CSS?</h2>
            <p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for HTML elements such as colors, backgrounds, fonts etc.</p>
        </article>
    </main>

    <footer>
        <p>copyright &copy; tutorialrepublic.com</p>
    </footer>
</body>
</html>

Tip: The content of the <main> element should be unique to the document. Content that is repeated across the documents such as sidebars, navigation links, copyright information, site logos, and search forms (unless it is the main function of the page) shouldn't be included.

Note: A document must not have more than one <main> element. Also, the <main> element must not be a descendant of an <article>, <aside>, <footer>, <header> or <nav> element.


Tag-Specific Attributes

The <main> tag doesn't have any specific attribute.


Global Attributes

Like all other HTML tags, the <main> tag supports the global attributes in HTML5.


Event Attributes

The <main> tag also supports the event attributes in HTML5.


Browser Compatibility

The <main> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 21+
  • Google Chrome 26+
  • Edge 12+
  • Apple Safari 7+
  • Opera 16+

Further Reading

See tutorial on: HTML Layout.

Related tags: <article>, <aside>, <footer>, <header>, <nav>.

Advertisements
Bootstrap UI Design Templates