Tag HTML <body>


Exemplo

Um documento HTML simples:

<html>
<head>
  <title>Title of the document</title>
</head>

<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
</body>

</html>

Mais exemplos de "Experimente você mesmo" abaixo.


Definição e uso

A <body>tag define o corpo do documento.

O <body>elemento contém todo o conteúdo de um documento HTML, como títulos, parágrafos, imagens, hiperlinks, tabelas, listas, etc.

Nota: Só pode haver um <body> elemento em um documento HTML.


Suporte ao navegador

Element
<body> Yes Yes Yes Yes Yes

Atributos Globais

A <body>tag também suporta os Atributos Globais em HTML .


Atributos do evento

A <body>tag também suporta os atributos de evento em HTML .



Mais exemplos

Exemplo

Adicione uma imagem de fundo a um documento (com CSS):

<html>
<head>
<style>
body {
  background-image: url(w3s.png);
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

Exemplo

Defina a cor de fundo de um documento (com CSS):

<html>
<head>
<style>
body {
  background-color: #E6E6FA;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

Exemplo

Defina a cor do texto em um documento (com CSS):

<html>
<head>
<style>
body {
  color: green;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>
</html>

Exemplo

Defina a cor dos links não visitados em um documento (com CSS):

<html>
<head>
<style>
a:link {
  color:#0000FF;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Exemplo

Defina a cor dos links ativos em um documento (com CSS):

<html>
<head>
<style>
a:active {
  color:#00FF00;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Exemplo

Defina a cor dos links visitados em um documento (com CSS):

<html>
<head>
<style>
a:visited {
  color:#FF0000;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

Páginas relacionadas

Tutorial HTML: Elementos HTML

Referência HTML DOM: objeto de corpo

Referência HTML DOM: propriedade document.body


Configurações padrão de CSS

A maioria dos navegadores exibirá o <body>elemento com os seguintes valores padrão:

Exemplo

body {
  display: block;
  margin: 8px;
}

body:focus {
  outline: none;
}