Page 64 - CA_165_V2.0_Flipbook
P. 64
The output of the preceding HTML code is as follows:
Text color is Red due to
<BODY TEXT = "RED">
BACKGROUND Attribute
The background attribute in the <BODY> tag is used to set an image as the background of a web page.
The syntax for using the BACKGROUND attribute with <BODY> tag is as follows:
<BODY BACKGROUND="IMAGE_FILENAME.EXTENSION">
If the image is located in the same folder as the HTML file, you can simply use the image's name with
its extension. This is called a relative path. A relative path specifies the location of a file in relation to
the current HTML file. It does not include the full file system path, making it shorter and easier to use.
This method is suitable when the HTML file and the image are stored in the same directory or in
subdirectories.
For example:
<BODY BACKGROUND="background_image.jpg">
If the image is not located in the same folder or is on a different drive in the system, an absolute path
should be used. An absolute path provides the full location of a file on your computer or web server,
starting from the root directory. This is useful when the image is not in the same folder as the HTML file
or when you need to ensure the browser can find the image regardless of the HTML file's location.
For example:
<BODY BACKGROUND="C:\images\background_image.jpg">
Notes
The BACKGROUND attribute is not supported in HTML5.
The following HTML code uses the BACKGROUND attribute to set the background of the web page:
<HTML>
<HEAD>
<TITLE>
Example of background attribute
</TITLE>
</HEAD>
62 Touchpad Computer Applications-X

