Elements in HTML

The HTML element usually goes in pairs, including the opening tag, closing tag, and the content inside the two tags.

The HTML element usually goes in pairs, including the opening tag, closing tag, and the content inside the two tags.

content

The HTML element is everything from the opening tag to the closing tag.

Example of HTML element

Learn HTML programming


HTML is a hypertext markup language.

  1. Open card is

     

    and
  2. The content of the element is' Learn HTML programming 'and' HTML is hypertext markup language. '
  3. Close tag is and

HTML elements without content are called empty elements. Empty element has no closing tag, for example
(used for line breaks).

Nested HTML elements

HTML elements can be nested (this element is in another element)

All HTML documents contain nested HTML elements.

The following example has 4 HTML elements.





Learn HTML programming


HTML is a hypertext markup language.




Explain the example

  1. Element Defined for both texts, with open tags and the closing tag is . The content of this element is another element (that is ).



Learn HTML programming


HTML is a hypertext markup language.




  1. Element Identify the entire body of the text, starting with the opening tag and end with a closing tag , the content is 2 other HTML elements (

     

    and

    ).



Learn HTML programming


HTML is a hypertext markup language.



  1. Element

     

    Define the title, have the opening tag

     

    and the closing tag is , the content is Learn HTML programming.

Learn HTML programming

  1. Element Identify the paragraph, including the opening tag and the closing tag is , the content is HTML is the hypertext markup language.

HTML is a hypertext markup language.

Don't forget the closing card

Although some HTML elements are still displayed correctly even if you forget the closing tag, the browser will still display the same way as the closing tag, for example, below.




Learn HTML programming


HTML is a hypertext markup language.




But don't rely too much on this because in other cases, it may cause an error when you forget the closing card.

Empty HTML element

Empty HTML elements are elements that do not contain content.


is an empty element, has no closing tag and is used to break the line.

Empty elements can 'close' at the opening tag like this />

HTML5 is not required to close the empty element. But if you want more rigorous validation or want your XML parsers to be readable, it's best to close all HTML elements properly.

Tags marked with uppercase and lowercase letters

HTML tags are not necessarily lowercase or uppercase,

good

are the same.

The HTML5 standard is not required to use lowercase letters, but W3C recommends lowercase letters in HTML and requires lowercase text for more demanding documents like XHTML.

Previous article: Basic examples of HTML

The following article: Properties in HTML

4 ★ | 2 Vote