HTML Element

HTML Element

An HTML element is usually made up of an <opening> tag and a </closing>

tag, with the content between the two tags. An HTML element is made up of everything from the opening tag to the closing tag:

Structure of HTML elements
				
					Opening Tag | Content | Closing Tag
-------- | ------------ | ---------
<h1> Document Heading </h1>
				
			
Note: Some HTML elements such as <br><hr>etc. have a different structure from the above. Since they do not have a closing tag, they are called empty tags.
Nested HTML elements

HTML elements can be nested, meaning there can be elements within elements.

All HTML documents are made up of nested HTML elements.

The following HTML document is made up of 6 HTML elements:

Examples
				
					<!DOCTYPE html>
<html>
<head>
<title>HTML Element</title>
</head>
<body>
<h3>Document Heading</h3>
<p>This is a paragraph.</p>
</body>
</html>
				
			
Output
HTML Example

This is a heading

This is a paragraph.

Example description
  • The first line of the HTML document above <!DOCTYPE html>refers to version 5 of HTML.

  • It <html>starts with the opening tag and </html>ends with the closing tag.

  • <head>The element contains additional information about the document<head> , such as the document title, document description, etc. It starts with the tag and </head>ends with the tag.

  • <title>The element contains the title or name of the document<title> . It starts with the tag and </title>ends with the tag.

  • Here <body>the element is the content element, that is, <body>the main part of the document.
				
					<body>
<h3>Document Heading</h3>
<p>This is a paragraph</p>
</body>
				
			
bodyPart Description:

It <body>started with the tag and </body>ended with the tag.

<h3>And <p>the two elements are content elements.

<h3>The element represents a heading .

				
					<h3>Document Heading</h3>
				
			

It starts with an opening tag and ends with a closing tag , and the content of this element is: Document heading.<h3></h3>

<p>An element represents a paragraph .

				
					<p>This is a paragraph</p>
				
			

It <p>starts with an opening tag and </p>ends with a closing tag, and the content of this element is: This is a paragraph.

Always use closing tags!
Examples
				
					<!DOCTYPE html>
<html>
<head>
<title>HTML Example</title>
</head>
<body>
<p>This is a paragraph
<p>This is another paragraph
</body>
</html>
				
			
Ouput
HTML Example

This is a paragraph

This is another paragraph

The above example works in all browsers, because the closing tag is considered optional in HTML5.

Note: This should never be relied upon, as it can give unexpected/incorrect results if you forget to include the closing tag.
Always use lowercase letters!

HTML tags are not case sensitive. For example, <code> <P>and <p><code> have the same meaning.

Lowercase is not mandatory in HTML(5). However, the W3C recommends using lowercase, and strict documents like XHTML require lowercase.

HTML Element

Leave a Comment

Your email address will not be published. Required fields are marked *