HTML makes use of various tags to format the content and these tags are enclosed within angle braces
<opening tag> content here...
In HTML a tag is used for creating an element. The name of an HTML element is the name used in angle brackets such as <p> for paragraph. Note that the end tag's name is preceded by a slash character, </p>, and that in empty elements the end tag is neither required nor allowed. If attributes are not mentioned, default values are used in each case.
An element is a part of a webpage. In XML and HTML, an element may contain a data item or a chunk of text or an image, or perhaps nothing. A typical element includes an opening tag with some attributes, enclosed text content, and a closing tag.
Elements and tags are terms that are widely confused.
A Tag is just opening or closing entity for example:
An Element encompasses opening tag, closing tag and content, for example:
<h1>I am Heading
<p>I am paragraph
|opening tag||Content||closing tag|
|<h1>||I am Heading||</h1>|
|<p>||I am paragraph||</p>|
The HTML element is everything from the opening tag to the closing tag:
There are some HTML elements which don't need closing tag, such as
<br>. These elements are called empty elements.
HTML elements with no content are called empty elements. They don't need closing tag.
Empty elements are also konwn as void element and self closing tags.
<br> is an empty element without a closing tag (the <br> tag defines a line break).
Below is a list of empty elements available in HTML:
|<area>||Defines an area inside an image-map|
|<base>||Specifies the base URL/target for all relative URLs in a document|
|<br>||Defines a single line break|
|<embed>||Defines a container for an external (non-HTML) application|
|<hr>||Defines a horizontal line|
|<img>||Defines an image|
|<input>||Defines an input control|
|<link>||Defines the relationship between a document and an external resource (most used to link to style sheets)|
|<meta>||Defines metadata about an HTML document|
|<source>||Defines multiple media resources for media elements|
|<track>||Defines text tracks for media elements|
|<wbr>||Defines a possible line-break|
HTML elements can be nested (elements can contain elements).
That means it is allowed to keep one HTML element inside another HTML element.
<p>This is <b>bold</b> text</p>
<p>This is <i>italic</i> text</p>
<p>This is <i><b>bold and italic</b></i> text</p>
HTML tags should be "nested" in a proper order, meaning that the tag opened most recently is always the next tag to close.