HTML <body> Tag


Voorbeeld

'n Eenvoudige 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>

Meer "Probeer dit self" voorbeelde hieronder.


Definisie en gebruik

Die <body>merker definieer die dokument se liggaam.

Die <body>element bevat al die inhoud van 'n HTML-dokument, soos opskrifte, paragrawe, beelde, hiperskakels, tabelle, lyste, ens.

Let wel: Daar kan net een <body> element in 'n HTML-dokument wees.


Blaaierondersteuning

Element
<body> Yes Yes Yes Yes Yes

Globale eienskappe

Die <body>merker ondersteun ook die Global Attributes in HTML .


Gebeurtenis eienskappe

Die <body>merker ondersteun ook die gebeurtenis-kenmerke in HTML .



Meer voorbeelde

Voorbeeld

Voeg 'n agtergrondprent by 'n dokument (met 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>

Voorbeeld

Stel die agtergrondkleur van 'n dokument (met 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>

Voorbeeld

Stel die kleur van teks in 'n dokument (met 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>

Voorbeeld

Stel die kleur van onbesoekte skakels in 'n dokument (met 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>

Voorbeeld

Stel die kleur van aktiewe skakels in 'n dokument (met 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>

Voorbeeld

Stel die kleur van besoekte skakels in 'n dokument (met 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>

Verwante bladsye

HTML-tutoriaal: HTML-elemente

HTML DOM verwysing: Body Object

HTML DOM verwysing: document.body Eiendom


Verstek CSS-instellings

Die meeste blaaiers sal die <body>element met die volgende verstekwaardes vertoon:

Voorbeeld

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

body:focus {
  outline: none;
}