body tag in html with example






  1. The body element wraps around all of the content that will be displayed on screen(or in other media, such as print), such as headings, paragraphs, images, tables, and so on. 
  2. The body tag defines the document's body.
  3. The body element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc
  4. It has some unique attributes, including alink, link, and vlink, all of which are now deprecated.
  5. The body is supported in all major browsers.


Example :

     <html>
     <head>
     <title>Body</title>
     </head>
     <body>
     <p>This is simple example on body element.</p>
     </body>
     </html>
     

Demo :






Body and Style :



<html>
<head>
<title>Paragraph</title>
<style type="text/css">
body
{
background:"black";
color:"silver";
font-size:"20px";
font-family:"comic sans ms";
}
a:hover
{
color:"orange";
}
</style>
</head>
<body>
<p>This is simple example on body element.</p>
<a href="http://www.99codingexamples.com" target="_blank">99codingexamples</a>
</body>
</html>
     

Demo :





We can apply CSS to elements inside a body using style.



Body and Javascript :



<html>
<head><title>Paragraph</title>
<script type="text/javascript">
function test()
{
document.bgColor="black";
}
</script>
</head>
<body>
<input type="button" id="b1" value="click" onclick="test()">
</body>
</html>
     

Demo :





In the above example, we have changed the background color using javascript.



0 comments:

Post a Comment