×

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

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.

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.

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 Reset Button

The HTML reset button is used to reset all values in the form. It clears all input fields. Reset is the value of the type attribute of the button element. The...

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 <style> tag

The section of information that we want to style is contained in html style tag. It includes CSS, which is used to design the text and images in the web page. Syntax: <head> <title>…………....

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 Date

The input element in HTML has several attributes. One of its attributes is the type attribute which creates a calendar in an order that a user can select a date...

5 minutes read.

HTML <video> Tag

The Video tag in HTML is used to play video on a media player on the web page. We can also insert an audio by the video tag, but audio...

6 minutes read.

HTML Code Tag

The code tag in HTML is a phrase tag used to insert a piece of computer programming code. In HTML there is a separate tag named as <code> tag. Sometimes,...

3 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

How to create a link with no underline in HTML

In HTML, an anchor tag (<a>) is a Styled Container tag, which means when a hyperlink is created using this, browsers, by default, display the link by applying some styles...

5 minutes read.

HTML Tutorial

Introduction This HTML tutorial helps beginners and professionals to learn HTML easily. HTML is a widely used web technology for website development. It stands for Hyper Text Markup Language. It is mainly used to...

7 minutes read.

How to insert spaces/tabs in text using HTML/CSS

What is HTML? HTML or HyperText Markup Language is used to design web pages. It was released in 1993. The file extension name for HTML file is “.html”. An HTML file...

4 minutes read.

Font tag in HTML

HTML stands for Hypertext Mark-up Language and is used to create web pages and other information that can be later displayed in a web browser. It also consists of a...

4 minutes read.

HTML Youtube

<object> element: It embed the object within the HTML documents and embed plug-ins such as Java applets, PDF readers, Flash Players etc in web pages. Example: <object width="100" height="100" data="bookmark.swf"></object> <embed> element: It defines an embedded...

1 minute read.

HTML <section> tag

The section element in HTML is used to define sections in a document. Syntax of Section Tag: <body> <h1>……….</h1> <section> <h2>……….</h2> <p> …………………………</p> </section> <section> <h2>………..</h2> <p>…………………………. <p> </section> </body> Examples of Section Tag Example 1: In this example, we use the HTML "section" element...

3 minutes read.

HTML Canvas

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

3 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.

HTML Frames

Frames in Html is used to divide the browser into different sections where each section can load different Html documents. Collection of frame is known as Frameset. Creating frames:We use frameset...

2 minutes read.