Attributes of <body> tag in html with example
HTML <body> tag defines the main content of an HTML document which displays on the browser. It can contain text content, paragraphs, headings, images, tables, links, videos, etc.
The <body> must be the second element after the <head> tag or it should be placed between </head> and </html> tags. This tag is required for every HTML document and should only use once in the whole HTML document.
Syntax
<body> Place your text here....</body>
Attribute
BodyTag specific Attributes
Attribute | Value | Description |
---|---|---|
a link | color | It defines the color of the active link in a document. (Not supported in HTML5) |
background | URL | It determines the background image for the document. (Not supported in HTML5) |
bg color | color | It determines the background color of the content. (Not supported in HTML5) |
link | color | It determines the color of the unvisited link. (Not supported in HTML5) |
text | color | It determines the color of the text in the document. (Not supported in HTML5) |
v link | color | It determines the color of the visited link. (Not supported in HTML5) |
onload | Function call on page loading | |
onunload | A function called when the user leaves the page | |
onfocus | A function called when the document receives focus from the user. | |
onblur | A function is called when a document loses focus by the user. |
Body Tag Examples
Example1
Set the color of visited links in a document with CSS:
<html>
<head>
<style>
a: visited {
color:#FFFF;
}
</style>
</head>
<body>
<p><a href="https://www.google.com">Google</a></p>
<p><a href="https://www.ar3school.com/html/">HTML Css Tutorial</a></p>
</body>
</html>
Example 2
Set the color of active links in a document with CSS:
<html>
<head>
<style>
a:active {
color:#00FF00;
}
</style>
</head>
<body>
<p><a href="https://www.ar3schools.com">Ar3school.com</a></p>
<p><a href="https://www.ar3schools.com/html/">HTML Css Tutorial</a></p>
</body>
</html>
Example 3
Set the color of unvisited links in a document with CSS:
<html>
<head>
<style>
a:link {
color:#0000FF;
}
</style>
</head>
<body>
<p><a href="https://www.ar3schools.com">ar3Schools.com</a></p>
<p><a href="https://www.ar3schools.com/html/">HTML Css Tutorial</a></p>
</body>
</html>
Example 4
Set the color of the text in a document with CSS:
<html>
<head>
<style>
body {
color: green;
}
</style>
</head>
<body>
<h1>Your text</h1>
<p>This is some text.</p>
<p><a href="https://www.ar3schools.com">Visit ar3Schools.com!</a></p>
</body>
</html>
Example 5
Set the background color of a document with CSS:
<html>
<head>
<style>
body {
background-color: #FFFF;
}
</style>
</head>
<body>
<h1>Your text</h1>
<p><a href="https://www.ar3schools.com">Visit our website</a></p>
</body>
Example 6
Add a background image to a document with CSS:
<html>
<head>
<style>
body {
background-image: url(Photolink.jpg);
}
</style>
</head>
<body>
<h1>Your text</h1>
<p><a href="https://www.ar3schools.com">Visit our website</a></p>
</body>
Default <body>CSS Settings
Most browsers will display the <body>
element with the following default values:
Example
body {
display: block;
margin: 10px;
}
body:focus {
outline: none;
}
Comments :
Post a Comment