HTML <body> -Tag


Beispiel

Ein einfaches HTML-Dokument:

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

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

</html>

Weitere „Probieren Sie es selbst“-Beispiele weiter unten.


Definition und Verwendung

Das <body>Tag definiert den Hauptteil des Dokuments.

Das <body>Element enthält alle Inhalte eines HTML-Dokuments wie Überschriften, Absätze, Bilder, Hyperlinks, Tabellen, Listen usw.

Hinweis: In einem HTML-Dokument kann es nur ein <body> Element geben.


Browser-Unterstützung

Element
<body> Yes Yes Yes Yes Yes

Globale Attribute

Das <body>Tag unterstützt auch die globalen Attribute in HTML .


Ereignisattribute

Das <body>Tag unterstützt auch die Ereignisattribute in HTML .



Mehr Beispiele

Beispiel

Fügen Sie einem Dokument ein Hintergrundbild hinzu (mit 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>

Beispiel

Legen Sie die Hintergrundfarbe eines Dokuments fest (mit 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>

Beispiel

Legen Sie die Textfarbe in einem Dokument fest (mit 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>

Beispiel

Legen Sie die Farbe von nicht besuchten Links in einem Dokument fest (mit 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>

Beispiel

Legen Sie die Farbe aktiver Links in einem Dokument fest (mit 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>

Beispiel

Legen Sie die Farbe besuchter Links in einem Dokument fest (mit 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>

Verwandte Seiten

HTML-Tutorial: HTML-Elemente

HTML-DOM-Referenz: Body-Objekt

HTML-DOM-Referenz: document.body-Eigenschaft


Standard-CSS-Einstellungen

Die meisten Browser zeigen das <body>Element mit den folgenden Standardwerten an:

Beispiel

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

body:focus {
  outline: none;
}