The HTML Body tag defines the main content of the document that will be directly visible on your web page. It contains text content , headings , paragraph , images , tables , links , videos , etc.
The body tag always placed within the tag, and it must be placed after the tag. This tag is required for every HTML document, and it should use only once in the whole HTML document.
Estimated reading time: 4 minutes
Syntax:
A Body tag contains both opening body tag and closing body tag.
<body>Place the content here</body>
Sample of the HTML body Tag:
<!DOCTYPE html>
<html>
<head>
<title>Document title</title>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
</body>
</html>
Result:
Example of the HTML body tag used with CSS Properties:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style>
body {
color: #082AC2;
line-height: 1.5;
}
</style>
</head>
<body>
<h1>HTML body Tag</h1>
<p>If your thoughts are as tall as the height of your ceiling, you can’t fly above your room.</p>
</body>
</html>
Result:
Attributes:
The body tag supports both Global Attributes and the Event Attributes.
Attribute | Value | Description |
---|---|---|
alink | color | This attribute defines the color of the active link.(Not used in HTML5) |
background | URL | It specifies the background image.(Not used in HTML5) |
bgcolor | color | This attribute will help to define the background color.(Not used in HTML5) |
link | color | It helps to specify the color of unvisited links.(Not used in HTML5) |
text | color | Helps to specify the color of the text in a document.(Not used in HTML5) |
vlink | color | This attribute will define the color of the visited link.(Not used in HTML5) |
Styling Methods for body Tag:
You can use the following properties to style an HTML body tag.
Properties to style the visual weight/emphasis/size of the text in body tag:
- CSS font-style – This CSS property helps to set the font style of the text such as normal, italic, oblique, initial, inherit.
- CSS font-family – This CSS property specifies a prioritized list of one or more font family names or generic family names for the selected element.
- CSS font-size – This CSS property will help to set the size of the font.
- CSS font-weight – This CSS property used to define whether the font should be bold or thick.
- CSS text-transform – This CSS property will control the text case and capitalization.
- CSS test-decoration – This CSS property specifies the decoration added to text such as text-decoration-line , text-decoration-color , text-decoration- style.
Styles to coloring the text in body Tag:
- CSS color – This CSS property will specify the color of the text content and decorations.
- CSS background-color – This CSS property helps to set the background color of an element.
Text layout styles for body Tag:
- CSS text-indent – This CSS property is used to specify the indentation of the first line in a text block.
- *CSS text-overflow * – This CSS property helps to describe how overflowed content that is not displayed should be signaled to the user.
- CSS white-space – This CSS property describes how white-space inside an element is handled.
- CSS word-break – This CSS property decides where the lines should be broken.
Other Properties for body Tag:
- CSS text-shadow – This CSS property helps to add the shadow to text.
- CSS text-align-last – This CSS property will set the alignment of the last line of the text.
- CSS line-height – This CSS property defines the height of a line.
- CSS letter-spacing – This CSS property helps to decide the spaces between letters/characters in a text.
- CSS word-spacing – This CSS property specifies the spacing between every word.
Browser Support:
Related Articles:
- HTML Big Tag
- HTML
- Basic HTML Definitions and Usages in the Real World
- HTML Bi-Directional Isolation Tag
- HTML Abbreviation Tag
The post HTML Body Tag appeared first on Share Point Anchor.
Top comments (0)