Earlier, we discussed HTML tags. The entire element, including everything between a start tag (eg <div>) and an end tag (eg </div>) is an element. An element can contain one or more elements, like tags. These are called nested elements. See the example below.
Here it is an HTML element with everything inside <html> </html> as a body element. Similarly, the rest are also one element.
Elements can contain elements within elements, such as <h1></h1> contains no elements, the text it contains is its content. So it's the h1 element with the text inside <h1></h1>.
This example is also given in DOC type. You can paste the code into an online editor, write it in notepad, save it with a .html extension (e.g., index.html or test.html), and open it in a browser.
This example has five elements: HTML element, head element, body, h1, and p element.
All other elements are child elements of HTML elements like tags. Again the body is the parent, and its children are the h1 and p elements. Elements that contain other elements are a parent and inner child elements.
No matter how many elements you write, you should write all inside the body element. You can write only certain elements inside the head elements. Only what is inside the body element is output to the browser.
There are two types of elements.
Block Level Elements: Elements that, by default, occupy the entire left and right space are called block level elements. In other words, elements that start on a new line (when displayed in the browser) are block-level elements. Block level elements like div, p, h1, ul, li, etc.
Inline Elements: Elements that do not start a new line are inline elements. Inline elements like a, i, b, span, strong, etc
Go to the online editor, enter the code, and click the "RUN" button to see the output.