BODY Tag

BODY Tag


The BODY tag contains all the text and graphics of the document with all the HTML tags that are used for control and formatting of the page.

The Format is:

<BODY>
Your Document goes here
</BODY>

An HTML document, web page can be created using a text editor, Notepad or WordPad. All the HTML documents should have the extension .htm or .html. It requires a web browser like Internet Explorer or Netscape Navigator/Communicator to view the document.

Attributes of <BODY> Tags


Attribute NameDescriptionPossible value
bgcolorto set the background of pagecolor name or hexadecimal color code
Ex: #FF0000 for Red color
backgroundto set the background image in pageurl or path
topmargin to define the margin from top of web pagepixel (px) or in percentage (%)
leftmargin to define the margin from left of web page
in updated browser it work for both left & right margin 
pixel (px) or in percentage (%)
textto set the text color of pagecolor name or color code in hexadecimal
linkto set the color of link textcolor name or color code in hexadecimal
vlinkto set the color visited linkcolor name or color code in hexadecimal
alinkto set the color of active linkcolor name or color code in hexadecimal


BGCOLOR: used to set the background color for the document

Example:

<BODY BGCOLOR="yellow">
Your document text goes here.
</BODY>


TEXT: used to set the color of the text of the document

Example:

<BODY TEXT="red"> 
Document text changed to red color 
</BODY>


LEFTMARGIN: set the left hand margin of the document

Example:

<BODY LEFTMARGIN="60">
This document is indented 60 pixels from the left hand side of the page.
</BODY>


TOPMARGIN: set the left hand margin of the document

Example:

<BODY TOPMARGIN="60"> 
This document is indented 60 pixels from the top of the page. 
</BODY>


BACKGROUND: It is used to point to an image file (the files with an extension .gif, .jpeg) that will be used as the background of the document. The image file will be tiled across the document.

Example:

<BODY BACKGROUND="filename.gif">
Your document text goes here
</BODY>


LINK: to set the color of link text. the default color of link is blue.

<BODY LINK="RED">
<a href="https://programmingtrick.com"> Infomax Academy</a>
</BODY>
VLINK : to set the color of visited link. The default color for visited link is purple.

<BODY VLINK="GREEN">
<a href="https://programmingtrick.com"> Infomax Academy</a>
</BODY>

ALINK : to set the color of active link i.e. when we click on a link.

<BODY ALINK="YELLOW">
<a href="https://programmingtrick.com"> Infomax Academy</a>
</BODY>


Lab Assignment 


Qus. 1 : What i s the correct HTML for adding a background color?

  1. <background>yellow<Background>
  2. <body color = yellow>
  3. <body bgcolor = yellow>
  4. <body bg =yellow>
Qus. 2 : How to insert a background image in HTML?

  1. <body background = "img.png">
  2. <img background = "img.png">
  3. <bg-image = "img.png">
  4. None of the above
Qus. 3 : The BODY tag is usually used after

  1. HTML tag
  2. HEAD tag
  3. TITLE tag
  4. EM tag
Qus. 4 : Which one is valid attribute of <body> tag

  1. color
  2. text
  3. font
  4. image
Qus. 5 : which one is invalid attribute of <body> tag

  1. bgcolor
  2. text
  3. color
  4. background
Qus. 6 : Which One is the valid color code for RED in Hexadecimal color scheme

  1. #FFFFFF
  2. #000000
  3. #FF0000
  4. #00FF00
Qus. 7 : Which attribute is used to set background color of html page?

  1. bgcolor
  2. background
  3. back color
  4. None of the above
Qus. 8 : Which tag is used to add a horizontal rule (line) in HTML

  1. <hr>
  2. <br>
  3. <line>
  4. <divider>
Qus. 9 : Which attribute is used to change the thickness of line in <hr> tag

  1. width
  2. size
  3. thickness
  4. weight

Programs

HTML code to display country name in red color

View Solution


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad