HTML <body> -tag
Voorbeeld
Een eenvoudig HTML-document:
<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 het zelf" voorbeelden hieronder.
Definitie en gebruik
De <body>
tag definieert de hoofdtekst van het document.
Het <body>
element bevat alle inhoud van een HTML-document, zoals koppen, alinea's, afbeeldingen, hyperlinks, tabellen, lijsten, enz.
Opmerking: er kan slechts één <body>
element in een HTML-document zijn.
Browserondersteuning
Element | |||||
---|---|---|---|---|---|
<body> | Yes | Yes | Yes | Yes | Yes |
Algemene kenmerken
De <body>
tag ondersteunt ook de Global Attributes in HTML .
Gebeurteniskenmerken
De <body>
tag ondersteunt ook de Event Attributes in HTML .
Meer voorbeelden
Voorbeeld
Een achtergrondafbeelding aan een document toevoegen (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 de achtergrondkleur van een document in (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 de kleur van tekst in een document in (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 de kleur van niet-bezochte links in een document in (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 de kleur van actieve links in een document in (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 de kleur van bezochte links in een document in (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>
Gerelateerde pagina's
HTML-zelfstudie: HTML-elementen
HTML DOM-referentie: Body Object
HTML DOM-referentie: document.body-eigenschap
Standaard CSS-instellingen
De meeste browsers geven het <body>
element weer met de volgende standaardwaarden:
Voorbeeld
body {
display: block;
margin: 8px;
}
body:focus {
outline: none;
}