Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML element

HTML element


An HTML document consists of a series of HTML elements, which form the basis of a web page's structure.


What is an HTML element?

An HTML element is the complete structure from the **start tagtoto the end tag**.

The opening tag Element content End tag

This is a paragraph

This is a link

Line break (empty element) None

Explanation:


HTML Element Syntax Rules

**Tip:** Attributes will be described in detail in later chapters.


Nesting of HTML Elements

HTML elements can be nested within one another, forming a tree structure:


HTML Document Example

  

    

This is the first paragraph.

  

This example contains three core elements:html、body、p。


Example walkthrough

element (paragraph)

This is the first paragraph.

Defines a paragraph containing text content.

element (body)

  

This is the first paragraph.

Defines the main content of the page and can contain multiple child elements.

element (root element)

  

    

This is the first paragraph.

  

The root node of the entire HTML document; all content must be contained within it.


About End Tags

In some cases, the browser automatically completes missing end tags:

This is a paragraph

This is another paragraph

Although it can be displayed normally,relying on this behavior is not recommended, as it may lead to:


HTML Empty Elements

Empty elements are elements with no content, for example:

Recommended notation:


This notation is compatible with HTML, XHTML, and XML, and is more standard.


Best practice: use lowercase tags

HTML tagCase-insensitive, but it is recommended to: