The <body>
tag in HTML is a fundamental element that contains the content of a webpage. This includes text, images, links, and other types of media or interactive elements. The <body>
tag represents the main content of the document and is placed inside the <html>
tag.
Common Attributes of the <body>
Tag
While the <body>
tag itself does not have many attributes compared to other HTML tags, it does support a few attributes for styling and scripting purposes:
background
(deprecated) - Specifies the URL of an image to use as a background for the page. This attribute is no longer recommended and has been replaced by CSS properties likebackground-image
.bgcolor
(deprecated) - Sets the background color of the page. Like thebackground
attribute, this is also outdated and should be replaced with CSS properties likebackground-color
.text
(deprecated) - Defines the color of the text in the document. This attribute has been replaced by CSS properties likecolor
.link
(deprecated) - Specifies the color of unvisited links. This attribute has been replaced by CSS properties.alink
(deprecated) - Sets the color of active links (links being clicked). Again, this should be handled with CSS.vlink
(deprecated) - Defines the color of visited links. This is also managed with CSS properties.
Here's an example demonstrating how to use these attributes:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example Page</title>
</head>
<body bgcolor="yellow" text="red" link="blue" alink="white" vlink=" green "
background="https://www.example.com/background.jpg" <!-- Background image -->
>
<h1>Welcome to My Web Page</h1>
<p>This is an example of using the <body> tag with attributes instead of CSS.</p>
<a href="https://smarttricks-tips.blogspot.com/">This is a link</a>
</body>
</html>
Explanation
background
: Sets an image as the background of the webpage.(Note that this attribute is deprecated and you should use CSS for this purpose in modern web design.)bgcolor
: Sets the background color of the page.text
: Sets the color of the text on the page.link
: Sets the color for unvisited links.alink
: Sets the color of links while they are being clicked (active state).vlink
: Sets the color of visited links.
0 Comments
Please do note create link post in comment section