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 the decorative scripts like CSS code or JavaScript code.

The <head> tag has it’s closing tag also which ends above the starting of the <body> tag, and each and every <head> tag content 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 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 in the page. 
  • <link> – The link element is used to link external files, such as style sheets or javascript file.
  • <style> – The style element includes the CSS rules. 
  • <script> – The script element include the javascript code and rules.
  • <meta> – Which include 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 that the <body> tag are given.

  • Bgcolor: Change the default background color 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 picture file like as 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'>

Related Articles

Back to top button

Adblock Detected

Please turn off your Adblocker to view your content.