HTML 04
- chathu hewage
- Feb 10, 2021
- 1 min read
Body Tag Formatting
In this tutorial you can study;
How to set body margin.
Color codes in Html.
How to use background color.
How to use text color.
How to put background images for a web page.
Body Margin
There are mainly four margins in html
Left margin
Right margin
Top margin
Bottom margin
We can set these margin for the body element
Example;
<body leftmargin="100" rightmargin="100" topmargin="100"
bottommargin="100">Hello </body>

Color Code

If you want to know about more color codes you can visit this web site;
Background Color
It is very common to see web pages with their background color set to white or some other colors.
In html you need edit Body element by adding Bgcolor attribute.

Text color
The TEXT attribute is used to control the color of all the normal text in the web page. The default color for text is black.
<body bgcolor=“#FFFFFF” TEXT=“#FF0000”>HELLO </body>
In this example you can get output like this

Background Image
The BODY element also gives you ability of setting an image as the document’s background.
An example of a background image’s HTML code is;
<BODY BACKGROUND IMAGE/BACKGROUND=“URL Or Image path” ></BODY>
You must enter image extension with image name such as;
.jpg
.gif
.jpeg
We can try any image as a web page background using above tags.
Examples
<html>
<body background="C:\Users\nawodya\Desktop\practical\CIT211\images\Uni_images\Picture6.jpg">
<h1> Hello</h1>
</body>
</html>
OR
<html>
<body background="Picture6.jpg“>
<h1> Hello</h1>
</body>
</html>

References:
Tutorial Created by Navodya Heshani
Comments