HTML < body> Tag: Definition, Usage, and Examples

The Power of HTML <body> Tag: A Beginner's Guide

HTML <body> Tag

{tocify} $title={Table of Contents}

HTML, or HyperText Markup Language, is a standard language used to create web pages. The “<body>” tag is one of the most important tags in HTML, as it is used to define the content that appears on a web page. 

In this blog post, we will discuss the “<body>” tag in detail, including its definition, usage, and examples.

Definition of the <body> Tag

The “<body>” tag is an HTML element that defines the main content of a web page. It is placed after the <head> tag and before the closing </html> tag

The “<body>” tag contains all the visible content of a web page, such as text, images, videos, and other media elements.

Usage of the <body> Tag

The “<body>” tag is used to define the content that appears on a web page. This includes all the visible elements that the user sees when they visit the web page. 

The “<body>” tag can contain various HTML elements, including headings, paragraphs, lists, tables, and forms.

The “<body>” tag also supports various attributes that can be used to define the behaviour and appearance of the content on the web page. 

Some common attributes include:

  • bgcolor: Specifies the background color of the web page.
  • text: Specifies the default text color for the web page.
  • link: Specifies the color of links on the web page.
  • vlink: Specifies the color of visited links on the web page.
  • alink: Specifies the color of active links on the web page.

Examples of the <body> Tag

Here are some examples of how the “<body>” tag can be used to create a web page:

Example 1: Basic HTML Structure

<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is my first web page using HTML.</p>
</body>
</html>{codeBox}

In this example, the <body> tag contains a heading (<h1>) and a paragraph (<p>) that define the content of the web page. 

The text “Welcome to My Web Page” is displayed as a large heading, and the text “This is my first web page using HTML”. is shown as a paragraph.

Example 2: Adding Images

<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is my first web page using HTML.</p>
<img src="image.jpg" alt="My Image">
</body>
</html>{codeBox}

In this example, an image is added to the web page using the <img> tag

The "src" attribute specifies the location of the image file, and the "alt" attribute specifies the text that should be displayed if the image cannot be loaded.

Example 3: Creating Links

<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
</head>
<body>
<h1>Welcome to My Web Page</h1>
<p>This is my first web page using HTML.</p>
<a href="https://www.example.com">Visit Example.com</a>
</body>
</html>{codeBox}

In this example, a link is added to the web page using the <a> tag

The "href" attribute specifies the URL of the web page that the link should point to, and the text "Visit Example.com" is displayed as the clickable link text.

Default CSS Settings

Most browsers will show the “<body>” element with the following default values.

Example:

body {
  display: block;
  margin: 8px;
}

body:focus {
  outline: none;
}{codeBox}

Conclusion:

Friends, according to my expertise, I have written complete information to help you with “HTML <body> Tag” If this post is favourable for you or not, please tell me by commenting.

If you liked this post, do not forget to share it with your friends so they can get information about it.

You can ask us through comments if you still have questions or doubts, I will answer all your questions, and you can contact us for more information.

Please tell us through the comment section if you think we miss anything.

To be published, comments must be reviewed by the administrator.*

Previous Post Next Post