body Tag in HTML
The <body>
tag is one of the most important tags in HTML, as it contains the main content of a web page. The <body>
tag is used to define the visible content of the web page that is displayed in the browser window. The content of the <body>
tag can include text, images, videos, links, and other media.
Syntax:
The syntax of the <body>
tag is as follows:
<html>
<head>
<!– head content goes here –>
</head>
<body>
<!– body content goes here –>
</body>
</html>
Attributes:
The <body>
tag does not have any required attributes, but it can accept several optional attributes. Here are some of the most commonly used attributes for the <body>
tag:
bgcolor
– Specifies the background color of the web page. This attribute takes a hexadecimal color code or a color name as its value.text
– Specifies the color of the text on the web page. This attribute takes a hexadecimal color code or a color name as its value.link
– Specifies the color of the links on the web page. This attribute takes a hexadecimal color code or a color name as its value.vlink
– Specifies the color of the visited links on the web page. This attribute takes a hexadecimal color code or a color name as its value.alink
– Specifies the color of the active links on the web page. This attribute takes a hexadecimal color code or a color name as its value.
Example:
Here is an example of how the <body>
tag can be used to define the content of a web page:
<html>
<head>
<title>My Web Page</title>
</head>
<body bgcolor=”#ffffff” text=”#000000″ link=”#0000ff” vlink=”#800080″ alink=”#ff0000″>
<h1>Welcome to my web page</h1>
<p>This is some text on my web page.</p>
<img src=”image.jpg” alt=”My Image”>
<a href=”https://www.example.com”>Click here to visit Example.com</a>
</body>
</html>
In this example, the <body>
tag is used to define the content of the web page. The bgcolor
, text
, link
, vlink
, and alink
attributes are used to specify the colors of the web page. The content of the <body>
tag includes a heading, some text, an image, and a link.
Conclusion:
The <body>
tag is an essential part of HTML, as it defines the visible content of a web page. The <body>
tag can include text, images, videos, links, and other media. By using the <body>
tag and its attributes, web developers can create web pages that are visually appealing and easy to navigate.