HTML <main>
Published Jan 16, 2022
Contribute to Docs
The <main> semantic tag represents the primary content within the <body> of the web page. This excludes content from other structural elements such as the header or footer.
Syntax
The <main> can be placed anywhere inside of the <body>:
<body>
<main>
<!-- Main content goes here. -->
</main>
</body>
Example
Below is an example of the <main> tag being used to display a list of notable lines from works by Shakespeare:
<!DOCTYPE html><html><head> </head><body><header><imgsrc="https://cdn.pixabay.com/photo/2014/04/03/11/50/drama-312318_640.png"width="200"height="200"/></header><main><h1>My Favorite Shakespeare Lines</h1><ul><li>"To be, or not to be: that is the question." - Hamlet</li><li>"Friends, Romans, countrymen, lend me your ears!" - Julius Caesar</li><li>"Shall I compare thee to a summer’s day? Thou art more lovely and moretemperate." - Sonnet 1</li></ul></main><footer><a href="https://en.wikipedia.org/wiki/William_Shakespeare">Learn more about William Shakespeare</a></footer></body></html>
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours