×

HTML <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML, which give the name to different types of material, such as heading, paragraph, link, etc. One of the most important elements in HTML is a body tag. You can't see the content on your Html document without a body tag.

The element <body> is used to show content in an HTML document. In a document, there can only be one "body" element. It should be placed after the <head> tag or between the end tag of the head and HTML tags. This is compulsory for all HTML documents.

Syntax of <body> tag

<body>
<h3>Hello World this is Content of your website
</h3>
</body>

Example of <body> tag in HTML

<!DOCTYPE html>
<html>
<body style="background-color:white;">
    <title>learning html</title>
<h1 style="color:rgb(17, 148, 224);"> how to learn html</h1>
<hr>
<p style="color:rgb(38, 165, 21);font-size: xx-large;font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;" 
>
The HTML element <body> is used to show content in an HTML document.It should be placed after <head> tag or between end tag of head and HTML tags. This is compulsory for all HTML document.


</p>


</body>
</html>

Output:

Html <body> tag

Attributes

Global Attribute

The global attributes are one set of properties for this element.

A link

Do not employ this quality! Instead, combine the active pseudo-class with the CSS colour property.

Background

Helps Find the URL of the background picture. Don't make use of this attribute! Use the element's CSS background property instead.

Link

The colour of the unclicked link is determined by this. It is not supportable in HTML5 so instead, use the: link pseudo-class and the CSS colour property.

Bg-color

The background colour of content is determined by it, but It is not supportable in HTML5, so instead, use the CSS background-colour property in HTML5.

Text

It shows the text colour in the HTML document, but it is not supportable in HTML5 so instead, use the CSS colour property in HTML5.

Vlink

It looks like a link, but its work is different. It shows the colour of the clicked link, also, it is not supportable in HTML5, so instead, use the: visited pseudo-class and the CSS colour property with it.

Onafterprint

Calling the function, when the user has finished printing the document.

Onbeforprint

Calling the function, when a user asks to print the document.

Onbeforunload

Calling the function shortly before the document is unloaded.

Onblur

Calling the function when the document becomes unfocused.

Onerror

Calling the function when the file cannot properly load.

Infocus

Calling the function when attention is directed toward the document.

Onhashchange

Calling the function when a change has been made to the document's current address's fragment identifier portion begins with the hash ('#') character.

Onlanguagechange

Calling the function when change comes in the preferable language.

Reload

Calling the function when the document file has loaded completely.

Onmessage

Calling the function when the document has received a message.

Onoffline

Calling the function when a network connection has been lost.

Ononline

Calling the function When a network connection is connected successfully.

Onpopstate

Calling the function after the user has browsed the session history.

Onredo

Calling the function when the user has advanced in the undo transaction history.

Storage

Calling the function after changing of storage area.

Onundo

Calling the function when the user moves forward in undoing transaction history.

Margin right

The body's right margin in the document is not supportable in HTML5 so instead, use the CSS margin-right property in HTML5.

Top Margin

The body's top edge margin in the document is not supportable in HTML5 so instead, use CSS margin-top

property in HTML5.

Browser Compatibility

  • Chrome
  • Safari
  • Edge
  • Opera Mini
  • Firefox

Conclusion

The HTML element <body> is used to show content in an HTML document. In a document, there can only be one "body" element. It supports many browsers like Chrome, Safari, Firefox, etc. It also supports many attributes like Global, Background Color, On storage, Ondo, etc. Without a body tag, you can't see your content on the HTML page, so it is an important element.


Related Topics

Design a tribute page using HTML and CSS

A tribute page is a webpage based on a person who inspired us in our life. In this article, we will create a webpage of Mahatma Gandhi. We are going...

5 minutes read.

HTML5 Tags

HTML5 Tags A list of newly included tags is provided in HTML5. These HTML 5 tags (elements) provide a better structure for the document. This list shows description of all HTML...

3 minutes read.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML References

BASIC HTML TAGS TAGS DESCRIPTION <!DOCTYPE> Defines Document Type <html> Defines Html document <head> Defines Header of document <title> Defines Title of document <body> Describe all the content of document <h1> to <h6> Defines Html Heading <p> Write Paragraph in this tag <br> Line break <!--...--> Comment in Html FORMATTING TAGS TAGS DESCRIPTION <abbr> Defines...

3 minutes read.

Most Commonly used Tags in HTML

In this tutorial, we'll look at the most popular HTML tags. We know HTML is a fundamental requirement for creating a website. As a result, it is essential to remember...

9 minutes read.

HTML Code

Before jumping into the topic, let’s understand a common scenario where we have a code snippet in our HTML file. By code snippet, we mean computer code, which is written...

5 minutes read.

HTML <source> tag

For media attributes, such as <video> tag, <audio> tag, and <picture> tag, we use the <source> tag in html for adding such type of multiple media html elements in our...

4 minutes read.

Div Tag in HTML

In HTML, ‘div’ is a tag that specifies division or section in HTML document. But before going in detail of it, let’s first understand about tags in HTML. The tag...

8 minutes read.

HTML <strike> tag

The HTML <strike> tag is used to specifies strikethrough text. The tag is deprecated now and <del> tag is used in HTML files instead of it. All the global and...

2 minutes read.

Html &lt;center> Tag

The term HTML refers to Hyper Text Markup Language. The most widely used markup language for making web pages is HTML. A structure of web page is described in HTML....

3 minutes read.

HTML5 Button Tag

HTML Button Tag The < button > tag is used on the webpage to construct a clickable button inside the HTML. Within the < button>....</button > tag, we can place content...

2 minutes read.

HTML Layouts

HTML Layouts HTML templates provide a way for well-managed, well-structured responsive web pages to be organized. We could say that the HTML layout specifies how web pages can be set up....

4 minutes read.

HTML <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML,...

3 minutes read.

HTML Form Input Types

HTML Form Input Types An important element of the HTML form is < input type= "> in HTML. The type attribute of the input element can be of different types, which...

8 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

HTML <sup> Tag

The HTML sup element is used to describe one or more superscript contents. The sup tag shows a text which is presented above the regular line and half the length...

2 minutes read.

HTML Data Tag

HTML Data Tag: The HTML < data > tag is used to transmit its content to a machine-readable version. The data are presented in a particular format. It is useful...

3 minutes read.

HTML <strong> tag

The strong element in HTML is used to display the real significant information in bold so that the user or reader will understand it easily. Syntax: <p> <strong>………… </strong> </p> Example Here, we will demonstrate how to...

2 minutes read.

HTML Button Disabled

The HTML <button> element has many attributes, one of them is the disabled attribute. The button on which you apply the disabled attribute will not work, or we can say...

4 minutes read.