Web Development

Head Element and Body Tag in HTML

HTML <HEAD> Element

The<head> element is just a container for all other header elements. It is the first thing to appear after the opening of the <html> tag.

Here the scriptwriter can show decorative scripts like CSS code or JavaScript code.

The <head> tag has its closing tag also which ends above the start of the <body> tag, and each and every <head> tag contains the <title> element to indicate the title of the web page on the title bar.

Inside the <head> element there we can use some more elements which are the following…

  • <base> – This transforms the relative URL into a full absolute URL. This element allows you to specify a base URL for a page. 
  • <object> – The website includes images, javascript objects, flash animations, mp3 files,  QuickTime movies, and other types of files on the page. 
  • <link> – The link element is used to link external files, such as style sheets or javascript files.
  • <style> – The style element includes the CSS rules. 
  • <script> – The script element include the javascript code and rules.
  • <meta> – Which includes the information about the document such as keywords and description which are particularly helpful for the search. This will web page for better search engine optimization.

HTML Body Tag

The tags used to indicate the start and end of the main body of textual information are:

<body>//starting body tag.
</body>//closing of body tag.

Page defaults like background color, text color, font size, font-weight, and so on can be specified as attributes of the <body> tag. The attributes of the <body> tag are given.

  • Bgcolor: Change the default background color, to whatever color is specified on it. We can define color as a hexadecimal value (#fff) or color name. (white, red, blue, etc).
  • Background: Specifies the name of a picture file like a Gif file that will be used as the background of the document.
  • Text: Change the body text color from its default value to the color specified by this attribute.
Parameter nameDescription
BACKGROUNDSpecifies an image to repeat as the background of the page
BGCOLORSpecifies a color to use as the background for the page
TEXTSpecifies the color of use as the default color for the text
LINKSpecifies the color to use for the link that has not been clicked
VLINKSpecifies the color to use for the link that has been clicked

Example 1,

<body bgcolor='#ff0000'> or <body bgcolor='red'>

Example 2,

<body background='picutre_name.jpg'>

While changing the background as an image, the image file should be present in the current working directory. If not relative path should be specified to where the image file exists.

Example 3,

<body text='black'> or <body text='#000000'>


About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

HTML introduction
Web Development

HTML – Introduction, History & Syntax

  • December 21, 2019
So, first of all, I would like to ask a question for the first time when you heard this term
html heading tag
Web Development

HTML – Heading Tag With Syntax

  • December 21, 2019
A heading tag is one of the most important tags we focus on in HTML or web development because, without