Learn Basic HTML Elements - HTML Tutorial

HTML element


HTML Elements



HTML documents are defined by HTML elements, which refer to all the code from the start tag to the end tag.

HTML Elements

* The Start tag is often called the opening tag, and the End tag is often called the closing tag.



HTML element syntax


  • HTML element to start tag start
  • HTML elements with an end tag termination
  • The content of the element is between the opening and closing tags
  • Some HTML elements have empty content
  • Empty elements are closed in the start tag (ending with the end of the start tag)
  • Most HTML elements can have attributes


Nested HTML elements

HTML documents are made up of nested HTML elements, which can contain other HTML elements. 

HTML document example

<!DOCTYPE html>
<html>

<body>
<p>This is the first paragraph.</p>
</body>

</html>
The above example contains three HTML elements.

HTML example parsing

<p> element:

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

<body> element:

<body>
<p>This is the 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 the 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
content of the element is another HTML element (body element).

Don't forget the closing tag

If you forget to use the closing tag, most browsers will also display the HTML correctly:
<p>This is a paragraph
<p>This is a paragraph
The above example will also display normally in the browser, because closing the tab is optional.
But you cannot rely on this, because forgetting to use end tags can have unpredictable results or errors.

HTML empty element

An empty HTML element is an HTML element with no content.
Empty HTML elements should be closed in the opening tag.
An empty element of HTML is <br> (used to define line breaks), and the <br> element is just without closing tags.
The closing method for empty HTML elements is to add a slash to the opening tag, such as <br />, which is accepted by HTML, XHTML, and XML.
Note: In XHTML, XML, and future versions of HTML, all elements must be closed, even empty elements.

HTML tip: Use lowercase tags

Because HTML tags are not sensitive to the case of English letters, <P> and <p> mean the same thing, but most sites prefer to use uppercase HTML tags.


Also see this:
Introduction to HTML
HTML Editors
HTML Basic Tags