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:
The example below shows the <main>
tag in action.
Example
Try this code »<!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 © 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.
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.
Basic Support—
|
Further Reading
See tutorial on: HTML Layout.
Related tags: <article>
, <aside>
, <footer>
, <header>
, <nav>
.