top of page

HTML Lecture 02 - The Elements

  • Writer: Alex Wright
    Alex Wright
  • Jun 6, 2020
  • 1 min read

Updated: Jul 1, 2022



HTML Elements


HTML Elements are defined by everything from the start tag to the end tag.

<h1> My Heading </h1>

<p> My paragraph. </p>

In the above example the line starting from h1 tag is one element and the next line starting with p tag is another element.


Note: Always remember to put an end tag at the end of every element, except the empty tags (Explained Later)


Nested HTML Elements


Elements in HTML can be nested which means one element can contain other elements.


In the above example, you can see the HTML root element that defines the whole HTML document starting with tag <html> and ends with </html> and inside the <html> element we have two other elements <head> and <body>.

Then we have the <body> element that defines the body of the document starting with <body> and ends with </body> and Inside the <body> element we have two other elements <h1> and <p>.

The <h1> element defines a heading and it starts with <h1> and ends with </h1>.

The <p> element defines a paragraph and it starts with <p> and ends with </p>.


Note: There are 6 different types of headings in HTML defined by the following tags <h1>, <h2>, <h3>, <h4>, <h5> and <h6>, with <h1> being the largest heading and <h6> being the lowest.


Empty HTML Elements


HTML elements with no content are called empty elements.

The above example shows a <br> tag within a <p> element. <br> tag is an example of empty HTML elements and this tag is without a closing tag. <br> tag is used for a line break in a HTML document.


2 Comments


madison
Jun 29, 2020

Good one

Like

chuck
Jun 29, 2020

nice post

Like
bottom of page