<body>
<body>
Tag
The HTML <body>
element defines the primary content of a webpage. Each HTML document can contain only one <body>
tag.
- Global Attributes: This element supports global attributes.
- Event Handlers:
Events such as
onload
,onerror
,onresize
, andonunload
can be triggered based on user interactions or system events.
Syntax
<body>
<!-- Content goes here -->
</body>
<body>
Demo
<h1>Welcome to My Website</h1>
<p>This is a paragraph of text.</p>
<img src="img.jpg" alt="A descriptive image">
<a href="https://institute.qarpeo.com">Visit https://institute.qarpeo.com</a>
<body>
tag contains all visible content, including a heading <h1>
, a paragraph <p>
, an image <img>
, and a link <a>
.Examples
- Set text color using CSS:
This is some text.
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: green;
}
</style>
</head>
<body>
<p>This is some text.</p>
<p><a href="https://institute.qarpeo.com">Visit https://institute.qarpeo.com</a></p>
</body>
</html>
- Set color for unvisited links using CSS:
<!DOCTYPE html>
<html>
<head>
<style>
a:link {
color: #FF0000;
}
</style>
</head>
<body>
<p><a href="https://institute.qarpeo.com">https://institute.qarpeo.com</a></p>
<p><a href="https://institute.qarpeo.com/cs/html">HTML Tutorial</a></p>
</body>
</html>
Purpose and Usage
- The
<body>
element defines the main content area of an HTML document. - It includes visible elements like headings, paragraphs, images, links, tables, and lists.
<body>
element.See Also
Conclusion
The <body>
tag in HTML is essential for defining the main content of a webpage, containing all visible elements like text, images, and links. It is the part of the document that is displayed to users in the browser. Each HTML document should have only one <body>
tag, and it can include global attributes and event handlers like onload
, onerror
, onresize
and onunload
to enhance interactivity.
<head>
The HTML <head> element holds metadata about the document, including the title, links to stylesheets, and scripts, which are essential for document processing and presentation but are not visible on the webpage.
<aside>
The HTML <aside> element represents supplementary content, like sidebars or pull quotes, that is related but not essential to the main content, often used for extra information.