HTML elementsLOGIN

HTML elements

Introduction to HTML elements

HTML documents are defined by HTML elements. HTML documents are composed of nested HTML elements

"HTML tag" and "HTML element" usually describe the same meaning.

But strictly speaking, an HTML element contains the opening tag With the closing tag,

the following example:

HTML element:<p>This is a paragraph.</p>

Starting tag Often called the opening tag (opening tag), the end tag is often called the closing tag (closing tag). The content of the

element is the content between the start tag and the end tag.

Note:Even if you forget to use the closing tag, most browsers will display the HTML correctly:

<p>This is a paragraph

The above example can also be displayed normally in the browser because closing the tag is optional. But don't rely on this approach. Forgetting to use a closing tag can produce unpredictable results or errors.

In a future version of HTML, omitting the closing tag will not be allowed.

HTML Empty Element

An HTML element without content is called an empty element. Empty elements are closed in the opening tag.

<br> is an empty element without a closing tag (<br> tag definition wraps).

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

Adding a slash in the opening tag, such as <br />, is the correct way to close an empty element, and is accepted by HTML, XHTML, and XML.

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

##Use lowercase tags

HTML tags are not case-sensitive: <P> is equivalent to <p>. Many websites use uppercase HTML tags.

W3CSchool uses lowercase tags because the World Wide Web Consortium (W3C) recommended lowercase in HTML 4 and will mandate lowercase in a future version of (X)HTML.

Other tags

The<hr> tag creates a horizontal line in the HTML page. Can be used to separate content.

<br> Tag defines line break. The <br /> element is an empty HTML element. Since a closing tag doesn't make any sense, it doesn't have a closing tag.


HTML Comment: <!-- This is a comment-->

Example:

<body> Elements:

<body><p>HTML is easy to learn! You will love it! </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>HTML is very Easy to learn! You will love it! </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).


Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <h1>春晓</h1> <p> 春眠不觉晓, 处处闻啼鸟。 夜来风雨声, 花落知多少。 </p> </body> </html>
submitReset Code
ChapterCourseware