The HTML document is defined by the HTML element. Start label Element content End tag < p > This is a paragraph. < / p > < a href= “default.htm” > This is a link. < / a > < br > New line The The HTML element starts with the opening tag The HTML element terminates with the closing tag The content of the element is the content between the start tag and the end tag Some HTML elements have empty content The empty element is closed in the start tag (ends with the end of the starttag) Most HTML elements can have attributes Note: you will learn more about attributes in the next chapter of this tutorial. Most HTML elements can be nested (HTML elements can contain other HTML elements). HTML documents are made up of HTML elements that are nested within each other. The above example contains three HTML elements. < p > element: This This element has a start tag The element content is: this is the first paragraph. The This element has a start tag The content of the element is another This element has a start tag The content of the element is another Even if you forget to use the closing tag, most browsers will display it correctly The above examples can also be displayed normally in the browser, because the closing tab is optional. But don’t rely on it. Forgetting to use the closing tag can produce unpredictable results or errors. A HTML element with no content is called an empty element. The empty elementis closed in the opening tag. In XHTML, XML, and future versions of HTML, all elements must be closed. Add a slash to the opening tag, such as even if The HTML tag is case-insensitive: Rookie tutorials use lowercase tags because the World wide Web Consortium (W3C) recommends lowercase in HTML 4 and enforces lowercase in future (X) HTML versions. 11.5.1. HTML element ¶
\*
start tag is often referred to as the start tagand the end tag is often referred to as the closing tag. 11.5.2. HTML element syntax ¶
11.5.3. Nested HTML elements ¶
11.5.4. HTML document instance ¶
<!DOCTYPE html>
<html>
<body>
<p>This is the first paragraph.</p>
</body>
</html>
11.5.5. Analysis of HTML instance ¶
<p>This is the first paragraph.</p>
<p>
element defines a paragraph in the HTML document.
<p>
and a closing tag
</p>
.
<body>
elements:<body>
<p>This is the first paragraph.</p>
</body>
<body>
element defines the body of the HTML document.
<body>
and a closing tag
</body>
.
HTML
element (p element).
<html>
elements:<html>
<body>
<p>This is the first paragraph.</p>
</body>
</html>
<html>
element defines the entire
HTML
documents.
<html>
and a closing tag
</html>
.
HTML
element (
body
element). 11.5.6. Don’t forget the closing tag. ¶
HTML
:<p>This is a paragraph
<p>This is a paragraph
11.5.7. HTML empty element ¶
<br>
is an empty element that does not close the tag
<br>
labeldefines a line break).
<br/>
is the right way to closeempty elements, which are accepted by HTML, XHTML, and XML
<br>
is valid in all browsers, but use the
<br/>
. In fact, it is a longer-term protection. 11.5.8. HTML hint: use lowercase tags ¶
<P>
equivalent to
<p>
. Many websites use uppercase HTML tags.