HTML tags are the basic building block of webpages. Tags are like a sign board which tells the browser how to display and format content inside the tag.
HTML tag starts and close with angle brackets (<tagname>) and the name of tag lies within the brackets. Example
HTML tags are used in nested form. Like:
<body> tags are used inside
<html> tag, inside
<title> tag and inside
<body> we use other tags like headings, paragraphs, etc.
The following example is a valid HTML code, you can see how HTML tags are nested in each other. Tags used in example below are
Note: HTML tags are always written in lowercase.
Lets discuss basic HTML tags here:-
<html>tag is called root tag of HTML document because it is root element in tree of elements of a web page.
- All other elements like head or body goes inside it.
- It contain all other element of web page except
<head>contain all necessary information related to web page but not actual content.
- Information like: title, base address, script, meta data, style all resides in
- Contents of
<head>element is not diaplayed in web page.
<body>tag defines body of HTML document.
- All the element which are displayed on web page lies inside
- Paragraphs, headings, images, videos,links every visible content is defined inside
- Heading tags are used to give headings in HTML documents.
- There are six levels of headings representing six different sizes of heading.
- Headings are <h1>,<h2>,<h3>,<h4>,<h5> and <h6>. Where <h1> is biggest in size and <h6> is smallest in size.
<p>tag defines paragraphs in HTML documents. It is used to write content on webpage in form of a paragraph.
- Writing content to one
<p>tag and then moving to the next
<p>tag automatically changes the paragraph in the web page.
Preformatted tag( pre tag)
<pre>tag allows you to define spacing and lining itself in an HTML document.
- Content on a web page is decorated in the same fashion as you define in
<table>tag is used to create tables on a webpage. table tag contains many helper tags which are used within table tag to create table-rows, table-columns, table-cells, etc.
- Some of helper table tags are
<list>tag is used to create lists on a webpage. list tag are of 2 types unordered and ordered list.
- Unordered list is created using
<ul>tag, whereas ordered list is created using
br tag (line breaking tag)
In HTML line breaking is specified by the
<br> tag is an empty tag. We do not need to close it in HTML but in XHTML it is not valid you have to close it as
<br>in HTML but in XHTML it's not valid instead we use
In HTML horizontal line is specified by the
<hr> tag is an empty tag.We need not to close it in HTML but in XHTML it is not valid you have to close it as
<hr>in HTML but in XHTML it's not valid instead we use
<center> tag is used to put any content in the center of the block of webpage.
- HTML tags are building blocks of webpage. HTML tags can be written in nested form.
- There are 2 different types of HTML tags closing tags like p tag, heading tag, div tag and self closing tag like br tag, hr tag, img tag, etc.
- html tags contains all tags nexted inside it.