What does the Body tag do in HTML: the most important element in HTML now?
body element contains all the content of a web page. It must be placed inside the
html parent element, next to the
<html> <head> . . . </head> <body>The content of the page should be here</body> </html>
The most important… and simplest
body element is the most important element in HTML. The content of the body element is what is actually shown to the user visiting your web page or viewing your document. The
body tag should be placed after the
html tag and after the
head tag (if present).
<html> <head> <title>The body tag in HTML</title> </head> <body> <h2>What does the Body tag do in HTML: the most important element in HTML now?</h2> <p>The body element contains all the content of a web page. It should be placed inside the html parent element, next to the head element.</p> </body> </html>
Styling with the body element
In previous versions of HTML (and in some proprietary browser markup schemes) a number of style attributes and events were available for the
body tag. These are all obsolete in HTML5. Any style you wanted to apply with the
body had to be placed in your CSS. And, in fact, the contents of the
body tag are a great place to put all the CSS that’s used to display the document as a whole: such as fonts and typography, text colors, backgrounds, and other default styles.
Targeting the body tag
A common practice in content management systems is to place a list of content-specific CSS classes in the
These classes are added programmatically by various components and plugins, and provide an easy way for developers to target styling or functionality to the highlighted page content (if not used, they cause no problems).