As mentioned in previous tutorials, HTML elements consits of Start and End tags. Also known as Opening and Closing tags. Between the tags we instert content and all of this together is what forms HTML elements.
So in short, the HTML element is everything from the start tag to the end stag.
|Start / Opening Tag||Content||End / Closing Tag|
Nested HTML Elements
It is possible to have nested HTML elements. (Elements within elements). Infact all HTML documents are made up of nested elements.
<h1>My First Heading</h1>
<p>My first paragraph.</p>
The <html> element ountlines and defines the entire document. There is a start and an end tag. The content of that <html> tag is another HTML element, the <body>.
The <body> element also has a start and end tag, within that is the body content which consists of a heading element <h1> and a paragraph <p> element.
The <h1> element defines a heading, again with a start and end tag. The content of the heading is: Heading 1.
The <p> element defines a paragraph, also with start and end tags wrapping around its content. The content of the <p> is: First paragraph.
Although modern browsers can and often render pages fine even with end tags missing, you should never do this. It can and will cause headaches, you will notice things not displaying as you thought they would and then diagnosing what is missing can cost a lot of time. Get into the habbit now of closing your tags. If youre forgetful then try using an editor that will help you by closing tags automatically.
However, sometimes in HTML5 we do not need to close tags. These are called empty elements. A perfect example of this is the <br> tag. It is possible and also recommended to actually close these tags, especially if you require your webpages to pass stricter HTML validation. <br /> is an example of a empty tag that is also closed. Nice and easy isnt it?
Are HTML tags case sensitive?
No. HTML tags are not case sensitive. <P> is also the same as <p>. The HTML5 web standard does not require lowercase tags, but it is highly recommended. We write all of our tags in lowercase for this reason. It is also required to be lowercase to get the most strict document validation types such as XHTML.