body tag in html with example
- 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.
- The body tag defines the document's body.
- The body element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc
- It has some unique attributes, including alink, link, and vlink, all of which are now deprecated.
- 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