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