HTML Document Structure:
An HTML document starts and ends with <html> and >/html> tags. These tags tell the browser that the entire document is composed in HTML. Inside these two tags, the document is split into two sections: The <head>...</head> elements, which contain information about the document such as title of the document, author of the document etc. Information inside this tag does not display outside.
The <body>...</body> elements, which contain the real content of the document that you see on your screen.
HTML Tags and Elements:
HTML language is a markup language and we use many tags to markup text. In the above example you have seen <html>, <body> etc. are called HTML tags or HTML elements.
Every tag consists of a tag name, sometimes followed by an optional list of tag attributes , all placed between opening and closing brackets (< and >). The simplest tag is nothing more than a name appropriately enclosed in brackets, such as <head> and <i>. More complicated tags contain one or more attributes , which specify or modify the behaviour of the tag.
According to the HTML standard, tag and attribute names are not case-sensitive. There's no difference in effect between <head>, <Head>, <HEAD>, or even <HeaD>; they are all equivalent. But with XHTML, case is important: all current standard tag and attribute names are in lowercase.
HTML is Forgiving?
A very good quality associated with all the browsers is that they would not give any error if you have not put any HTML tag or attribute properly. They will just ignore that tag or attribute and will apply only correct tags and attributes before displaying the result.
We can not say, HTML is forgiving because this is just a markup language and required to format documents.
HTML Basic Tags
The basic structure for all HTML documents is simple and should include the following minimum elements or tags:
- <html> - The main container for HTML pages
- <head> - The container for page header information
- <title> - The title of the page
- <body> - The main body of the page
Remember that before an opening <html> tag, an XHTML document can contain the optional XML declaration, and it should always contain a DOCTYPE declaration indicating which version of XHTML it uses.
Now we will explain each of these tags one by one. In this tutorial you will find the terms element and tag are used interchangeably.
The <html> Element:
The <html> element is the containing element for the whole HTML document. Each HTML document should have one <html> and each document should end with a closing </html> tag.
Following two elements appear as direct children of an <html> element:
- <head>
- <body>
As such, start and end HTML tags enclose all the other HTML tags you use to describe the Web page.
The <head> Element:
- The <head> element is just a container for all other header elements. It should be the first thing to appear after the opening <html> tag.
- Each <head> element should contain a <title> element indicating the title of the document, although it may also contain any combination of the following elements, in any order:
- The <base> tag is used to areate a "base" url for all links on the page. Check HTML Base tag.
- The <object> tag is designed to include images, JavaScript objects, Flash animations, MP3 files, QuickTime movies and other components of a page. Check HTML Object tag.
- The <link> tag is used to link to an external file, such as a style sheet or JavaScript file. Check HTML Link tag.
- The <style> tag is used to include CSS rules inside the document. Check HTML Style tag.
- The <script> tag is used to include JAVAScript or VBScript inside the document. Check HTML Script tag.
- The <meta> tag includes information about the document such as keywords and a description, which are particularly helpful for search applications. Check HTML Meta tag.
Example:
<head>
<title>HTML Basic tags</title>
<meta name="Keywords" content="HTML, Web Pages" />
<meta name="description" content="HTML Basic Tags" />
<base href="http://www.tutorialspoint.com" />
<link rel="stylesheet" type="text/css" href="tp.css" />
<script type="text/javascript"> _uacct = "UA-232293"; urchinTracker(); </script>
</head>
The <title> Element:
You should specify a title for every page that you write inside the <title> element. This element is a child of the <head> element). It is used in several ways:
- It displays at the very top of a browser window.
- It is used as the default name for a bookmark in browsers such as IE and Netscape.
- Its is used by search engines that use its content to help index pages.
Therefore it is important to use a title that really describes the content of your site. The <title> element should contain only the text for the title and it may not contain any other elements.
Example:
Here is the example of using title tag.
<head>
<title>HTML Basic tags</title>
</head>
No comments:
Post a Comment