BIT251 ยท 2081 ยท 5 marks
What are the usages of Main and Aside tags? Write HTML script using these tags. [3+2]
What are the usages of Main and Aside tags? Write HTML script using these tags. [3+2]
Web Technology IChapter 2: HTML Basics and StructureMain and article tags
Quick answer
The <main> tag is used to specify the main content of a document. It represents the dominant content of the <body> of a document.
Main and Aside Tags in HTML
Usages of <main> Tag
Key points:
- There should be only one
<main>element in a document - The content inside
<main>should be unique to the document - It helps screen readers and search engines identify the primary content
- It excludes content that is repeated across pages like navigation bars, headers, footers, and sidebars
Usages of <aside> Tag
The <aside> tag is used to define content that is placed aside from the main content. It represents content that is indirectly related to the surrounding content.
Key points:
- Used for sidebars, pull quotes, advertisements, or related links
- The content inside
<aside>is tangentially related to the main content - It is often displayed as a sidebar in a webpage
- Helps in semantic structuring of the webpage
HTML Script Using <main> and <aside> Tags
<!DOCTYPE html>
<html>
<head>
<title>Main and Aside Example</title>
<style>
main {
width: 70%;
float: left;
background-color: #f0f0f0;
padding: 10px;
}
aside {
width: 25%;
float: right;
background-color: #d0e4f7;
padding: 10px;
}
</style>
</head>
<body>
<header>
<h1>My Website</h1>
</header>
<main>
<h2>Welcome to the Main Content</h2>
<p>
This is the primary content of the webpage.
It contains the most important information
that the user is looking for.
</p>
<p>
HTML5 semantic tags help organize content
in a meaningful and accessible way.
</p>
</main>
<aside>
<h3>Related Links</h3>
<ul>
<li><a href="#">HTML Tutorial</a></li>
<li><a href="#">CSS Tutorial</a></li>
<li><a href="#">JavaScript Guide</a></li>
</ul>
<h3>Advertisement</h3>
<p>Buy our new book on Web Development!</p>
</aside>
<footer style="clear:both;">
<p>Copyright 2024. All rights reserved.</p>
</footer>
</body>
</html>
Output Structure
| Section | Tag Used | Purpose |
|---|---|---|
| Primary content area | <main> | Holds the main article/content |
| Sidebar area | <aside> | Holds related links and ads |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.