Basically HTML elements are consist of start tag, end tag and content inserted between them.
HTML document is made up of html elements.
Note: Some elements does not have content and end tag, those elements are called self closing or empty elements.(For e.g: <img>, <hr>, <br> ).
HTML documents consist of a tree of these HTML elements and they describe how HTML documents should be built, and what kind of content should be placed in what part of an HTML document.
A tag is a part of an HTML element and an HTML element is the combination of a start-tag, content and end-tag.
For E.g: <p> This is a short paragraph </p>
In above example <p> and </p> are HTML tags and <p> is called opening tag while </p>is called closing tag. And the complete line <p>This is a short paragraph </p> is called HTML element.
Nested HTML Elements:
HTML tags are the block around the content. Sometimes, you need to place one element inside another element. Those “inner” elements are nested inside of others.
Every HTML document consist of nested HTML elements.
The <html> element defines the whole document. The html element has start tag and end tag.
<body> element is inside the <html> element and inside the <body> element is two other elements i.e <h2> and <p>, which means body element is nested inside the html element and and <p> and <h2> elements are nested inside the <body> element.
Block level elements and inline elements:
HTML element has a default display value depending on the type of element.
The display values are: Block-level and inline
Block Level HTML Elements:
A block-level element always starts on a new line and takes the full width of a page, from left to right
A block-level element can take one line or multiple lines and has a line break before and after the element
The block level elements can contain block-level as well as inline elements
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok