HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
A simple HTML document
The <body>
tag defines the document's body.
The <body>
element contains all the contents of an HTML document, such as
headings, paragraphs, images, hyperlinks, tables, lists, etc.
<body>
element in an HTML document.
Element | |||||
---|---|---|---|---|---|
<body> | Yes | Yes | Yes | Yes | Yes |
The <body>
tag also supports the Global Attributes in HTML.
The <body>
tag also supports the Event Attributes in HTML.
Add a background image to a document (with CSS):
<html>
<head>
<style>
body {
background-image: url(w3s.png);
}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p><a href="/">Visit W3C!</a></p>
</body>
Set the background color of a document (with CSS):
<html>
<head>
<style>
body {
background-color: #E6E6FA;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p><a href="/">Visit W3C!</a></p>
</body>
Set the color of text in a document (with CSS):
<html>
<head>
<style>
body {
color: green;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="/">Visit W3C!</a></p>
</body>
</html>
Set the color of unvisited links in a document (with CSS):
<html>
<head>
<style>
a:link {
color:#0000FF;
}
</style>
</head>
<body>
<p><a
href="/">W3C</a></p>
<p><a
href="/html/">HTML Tutorial</a></p>
</body>
</html>
Set the color of active links in a document (with CSS):
<html>
<head>
<style>
a:active {
color:#00FF00;
}
</style>
</head>
<body>
<p><a
href="/">W3C</a></p>
<p><a
href="/html/">HTML Tutorial</a></p>
</body>
</html>
Set the color of visited links in a document (with CSS):
<html>
<head>
<style>
a:visited {
color:#FF0000;
}
</style>
</head>
<body>
<p><a
href="/">W3C</a></p>
<p><a
href="/html/">HTML Tutorial</a></p>
</body>
</html>
HTML tutorial: HTML Elements
HTML DOM reference: Body Object
HTML DOM reference: document.body Property
Most browsers will display the <body>
element with the following default values:
body {
display: block;
margin: 8px;
}
body:focus {
outline: none;
}