HTML element

HTML documents are defined by HTML elements.

HTML element

The HTML element refers to all the code from the start tag to the end tag.

To the following

 Start tag Element contentEnd tag
 <p>This is a paragraph</p>
  <a href="" ><itd> </body>

Note: Start tags are often referred to as opening tags, and end tags are often referred to as closing tags.

HTML element syntax

  • HTML element starts with a start tag

  • HTML element terminated with end tag

  • The content of the element is the content between the start tag and the end tag

  • Some HTML elements have empty content

  • Empty elements are closed in the start tag (ends with the end of the start tag)

  • Most HTML elements can have attributes
Tip: You'll learn more about properties in the next chapter of this tutorial.

Nested HTML elements

Most HTML elements can be nested (can contain other HTML elements).
HTML documents consist of nested HTML elements.

The above example contains three HTML elements. Are <p> elements, <body> elements, <html> elements

HTML instance explanation

<p> Element:


<p>this is my first paragraph.</p>
This <p> element defines a paragraph in the HTML document.
This element has a start tag <p> and an end tag</p>.
The element content is: this is my first paragraph.

<body> element:
<body> 
<p>dis is my first paragraph.</p> 
</body>
The <body> element defines the body of the HTML document.
This element has a start tag <body> and an end tag </body>.
The element content is another HTML element (p element).

<html> element:
<html> 
<body> 
<p>This is my first paragraph.</p> 
</body> 
</html>
The <html> element defines the entire HTML document.
This element has a start tag <html> and an end tag</html>.
The element content is another HTML element (the body element).

Don't forget to end the label

Even if you forget to use the end tag, most browsers will display the HTML correctly:
 
<p>this is a paragraph

Instance


Program running result:

This is a paragraph
This is a paragraph    

The above example is fine in most browsers, but don't rely on it. Forgetting to use the end tag can produce unpredictable results or errors.

Note : Future HTML versions do not allow omitting the end tag.

Empty HTML element


HTML elements without content are called empty elements. Empty elements are turned off in the start tag.

<br> is an empty element that does not close the tag (<br> tag defines a line break).

In XHTML, XML, and future versions of HTML, all elements must be closed.

Adding slashes to the opening tag, such as <br />, is the correct way to turn off empty elements. HTML, XHTML, and XML all accept this.

Even though <br> is effective in all browsers, using <br /> is a longer-term guarantee.

Tip : HTML tags are not case sensitive: <P> is equivalent to <p>, but lowercase is recommended


Last Updated: 2018-07-06 12:32:44 By akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :