HTML Css body tag Ar3school tutorial

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

AttributeValueDescription
a linkcolorIt defines the color of the active link in a document. (Not supported in HTML5)
backgroundURLIt determines the background image for the document. (Not supported in HTML5)
bg colorcolorIt determines the background color of the content. (Not supported in HTML5)
linkcolorIt determines the color of the unvisited link. (Not supported in HTML5)
textcolorIt determines the color of the text in the document. (Not supported in HTML5)
v linkcolorIt determines the color of the visited link. (Not supported in HTML5)
onloadFunction call on page loading
onunloadA function called when the user leaves the page
onfocusA function called when the document receives focus from the user.
onblurA 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