Body HTML: HTML is a markup language used for creating a web page framework and structure. It creates the blueprint of the web page, where many elements such as title, heading, paragraph, links, audio, and other elements are embedded. The <body> tag holds the major contents of the HTML document. Let us know more about Body HTML tags in this article.
What is a Body HTML tag?
A body html tag is one of the major elements of HTML markup language used to enclose the main components of an HTML document. The contents of the body’s HTML tags are visible on the web page. They contain hyperlinks, images, audio, videos, and other elements.
- The <body> tags are the container elements in HTML document.
- It is placed inside the <html> tag in an HTML document and closed before closing the <html> tag.
- The <body> tag contains the actual element of web page.
- It consists of starting and ending tags.
- They are not self closing tags.
Body HTML Tag: Definition and Use
The <body> tag in HTML is used for enclosing visible contents of HTML such as links, texts, audio, videos and other elements. The syntax of the HTML body element is an angular bracket with the body typed inside. The Body HTML elements are not case-sensitive.
- The <body> html tag is a container for all visible elements inside an HTML document.
- All text, images and other multimedia elements that you want to display on the client side.
- They are a crucial part of HTML document structure.
- Javascript and CSS codes are embedded inside the body html elements.
Body HTML Element: Example
Let us understand <body> HTML tag with the help of an example in the table below.
Body HTML Elements |
<html>
<head> <title>Title of the web page</title> </head> <body> <h1>Welcome to My Webpage</h1> <p>This is the main content of this document.</p> <ul> <li><a href=”#link1″>Link 1</a></li> <li><a href=”#link2″>Link 2</a></li> <li><a href=”#link3″>Link n</a></li> </ul> </body> </html> |
The above example shows how the <body> tag encloses the heading, paragraph, and links inside it. They are to be displayed on the web page. Body html tags are always closed before the <html> tags. After closing the body HTML tags, there are no visible contents on the web page.
Recommended Technical Course
- Full Stack Development Course
- Generative AI Course
- DSA C++ Course
- Data Analytics Course
- Python DSA Course
- DSA Java Course
Body HTML Tags: Tag Attributes
You can easily embed various attributes inside the <body> tag in HTML. Check some of them below.
Body HTML Tags Attributes | |
Name of attributes | Description |
bgcolor | This attribute is used to set the background colour of HTML elements displayed on the web page. It can be given in hexadecimal form or just with the name of color. |
text | It sets the color of text using the color name or hexadecimal value. |
link | The link attribute is used to set colors to the unvisited link on the web page. |
alink | This attribute is used to set the colours for the active links. |
vlink | It is used to set the color of visited links on the web page. |
onload | It is used to set particular javascript functions executed after loading complete. |
onunload | This attribute is used to specify functions that will be executed when a user leaves the page. It saves the state of the web page and manages cleaning tasks. |
class | A class tag is used to give a name to the body html element. It can be used in the link stylesheets to access the appearance of body page appearances. |
id | This attribute gives a unique identifier to the body html element. It can be used in CSS and Javascript pages to define the appearance of HTML documents. |
Also Check: Best Web Development Agency: Top 10+ Web Development Companies for 2024
Body HTML Elements: Examples of bgcolor and text
Let us check the use of bgcolor and text used to give background color to HTML documents and text. We can use different other attributes a similar way.
Body HTML Elements |
<html>
<head> <title>Title of the web page</title> </head> <body bgcolor= “#FF000” text= “ FFA500”> <h1>Welcome to My Webpage</h1> <p>This is the main content of this document.</p> <ul> <li><a href=”#link1″>Link 1</a></li> <li><a href=”#link2″>Link 2</a></li> <li><a href=”#link3″>Link n</a></li> </ul> </body> </html> |
Also Read: Beautify HTML
Join Web Development Course on PW Skills
Learn web development with our quality-assured and affordable online Web Development Course. Step ahead and make a bright career as a full stack web developer with this all in one course.
The course consists of recorded and live lectures, doubt sessions, practice exercises, assignments and assessment tests. The course also consists of real time projects, free online compiler, course completion certificates and much more. Hurry to know more at @pwskills.com.
For Latest Tech Related Information, Join Our Official Free Telegram Group : PW Skills Telegram Group
Body HTML Elements FAQs
Is the body HTML tag case sensitive?
No, the body Html tag is not case-sensitive. HTML tags are not case-sensitive.
Is the body tag a self closing tag?
The HTML elements are not self-closing. They consist of an opening and closing tag.
What is a body html tag used for?
The tag in HTML is used for enclosing visible contents of HTML, such as links, texts, audio, videos and other elements.
What is the syntax of the element tag?
The syntax of the HTML body element is an angular bracket with the body typed inside. It is represented by .....