HTML tags can be considered as hidden keywords or commands incorporated in HTML, which holds the capability to define how your browser will display the content and format of the web page. Most tags of HTML have two sections: an opening and a closing portion, and any text is written within that has its effect based on the working of the tag. The most common example is the <html> tag, which has both a starting tag and ending tag.
- All HTML documents begin with <! DOCTYPE html>.
- The HTML document begin with <html> and ends with </html>.
- The HTML code inside the <head> and </head> tags of the HTML document is invisible. It contains other information related to the webpage.
- Only the content inside the <body> and </body> tags are displayed in the browser.
HTML tag which is usually written as <html>…. </html> or <HTML>…. </HTML> is the only tag which is a must for writing HTML pages. HTML tag has both a opening <html> and a closing tag </html>. The closing of tags is done by a forward slash (/) at the very start of the tag name. These types of tags having both opening and closing tags are called container tags, and those who only have an opening tag and no closing tag are called empty tags.
The HEAD tag is another important tag used to add the header in HTML. It is used to give various additional information about the page along with description and title to your page, which gets displayed in the title bar or acts as an indicator of what information to use or on which page you are currently in. The TITLE Tag is written within this HEAD tag.
Here is a simple example of all the above three tags:
<!DOCTYPE html> <html> <head> <title>This is page title.</title> </head> </html>
This tag is used to give the body, i.e., the visible section of the HTML document. All formatting and writing of content are done in this section within the opening <body> and the closing </body> tag. If your HTML code does not have a body tag associated with it, the HTML code will still run as written in the above example (only show the title in the title bar). This tag contains the information and formatting that will be seen in the main web browser in the form of a web page.
It is to be noted that, together, these three necessary tags, <html>, <head>, and <body>, make up the skeleton of an XHTML document, and these are the only foundation tags upon which all web pages are created or developed.
<!DOCTYPE html> <html> <head> <title>This is page title.</title> </head> <body> <h2>This is page heading.</h2> <p>This is my first <strong>paragraph text</strong>.</p> </body> </html>