The <body> tag in HTML is used to define the main content present inside an HTML page. It is always enclosed within <HTML> tag. The <body> tag is the last child of the <html> tag. The <body>
 tag contains all the contents of an HTML document, such as headings, images, hyperlinks, tables, lists, paragraphs, etc.
Syntax:Â
<body> Body Contents... </body>
Attributes:
There are many attributes in the <body> tag that are depreciated from HTML5 are listed below:Â
background
|
It contains the URL of the background image. It is used to set the background image.
|
bgcolor
|
It is used to specify the background color of an image.
|
alink
|
It is used to specify the color of the active link.
|
link
|
It is used to specify the color of visited links.
|
text
|
It specifies the color of the text in a document.
|
vlink
|
It specifies the color of visited links.
|
Example 1: In this example we will use HTML body tag in which all content placed inside the body tag.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< title >Document</ title >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >body Tag</ h2 >
< p >This is paragraph text</ p >
</ body >
</ html >
|
Output:Â
Example 2: In this example we will show the functioning of a Body tag along with its CSS implementation.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< title >Document</ title >
</ head >
< body style = "background-color:seagreen" >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML body Tag</ h2 >
< p >
This is paragraph Tag
</ p >
</ body >
</ html >
|
Output:Â sou
Supported Browsers:Â
- Google Chrome 1
- Edge 12
- Firefox 1
- Opera 15
- Safari 1
Last Updated :
29 Dec, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...