Previous Next

HTML Elements

HTML elements are usually defined with start tag and end tag, and content inserted in between.

<p>Content goes here...</p>

Example 

Start Tag Element Content End Tag
<p> This is paragraph content. </p>
<h1> This is heading content. </h1>
<div> This is division content. </div>
<br />    

HTML elements with no content are called empty elements like <br />

Empty elements do not have end tag. 

Empty element contains a forward slash after tag name, and there is space between tag name and forward slash. 

 

Difference between HTML Tag and HTML element

An HTML element is composed of HTML tags, start tag and corresponding closing tag. With content between them. 

Example

<p>Content goes here...</p>

Explanation

Here  <p> is start tag of paragraph and </p> is the closing tag of HTML element.

Complete <p>Content goes here...</p> is element.

 

Nested HTML Elements

HTML element can be nested (i.e. one element can contain another element).

All HTML documents are example of nested elements.

Example

<!DOCTYPE html>
<html>
   <body>
      <h1>My First Heading</h1>
      <p>My first paragraph.</p>
   </body>
</html>

Result:

My First Heading

My first paragraph.

Explanation:

Here html is the root level element in a HTML document.

body element is nested inside html element.

body contains nested h1 tag.

body element also contains nested paragraph p element.

 

HTML Empty Elements

HTML elements without any content are called as empty elements.

Empty elements contains a forward slash at the end of the start tag.

Example

<hr />
<img src="http://images.gofreedownload.net/beautiful-small-flowers-vector-78762.jpg" alt="flower" height="425" width="321" />

 


Previous Next