HTML Tutorial
<body>The <body> tag defines the main content of an HTML document. It contains all the visible elements on a web page, including text, images, videos, and interactive elements.
<body>The <body> tag has several attributes that can be used to customize its appearance and functionality:
background-color, which sets the background color.<body><body>
<h1>Hello World</h1>
<p>This is my first HTML page.</p>
</body>
In this example, the <body> tag contains a heading and a paragraph. The background color is set to white using the background-color attribute.
<body background="image.jpg">
<h1>Welcome to our website</h1>
<p>Explore our latest products and services.</p>
</body>
In this example, the background image of the body is set to image.jpg.
<body> TagTo explore the <body> tag, open your favorite text editor and create a new HTML file. Type the following code:
<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
<p>This is my first HTML page.</p>
</body>
</html>
Save the file and open it in a web browser. You should see a web page with a heading that says "Hello World" and a paragraph that says "This is my first HTML page."
When using the <body> tag, consider the following accessibility and ease of use best practices:
<h1> for headings and <p> for paragraphs instead of relying solely on the <body> tag to define the content.