HTML documents are defined by HTML elements.
HTML elements
The HTML element refers to all the code from the start tag (start tag) to the end tag (end tag).
Note: The start tag is often called an open tag (opening tag), and the end tag is often referred to as a closed tag (closing tag).
HTML element syntax
- HTML element to start tag starting
- HTML element terminated with end tag
- The content of an element is the content between the start tag and the end tag
- Some HTML elements have blank content (empty contents)
- Empty elements are closed in the start tag (ending with the end of the start tag)
- Most HTML elements can have properties
tip: You'll learn more about properties in the next chapter of this tutorial.
Nested HTML elements
Most HTML elements can be nested (other HTML elements can be included).
HTML documents are composed of nested HTML elements.
HTML document Instance
< HTML > < Body > < P > This is my first paragraph. </ P > </ Body > </ HTML >
The above example contains three HTML elements.
HTML instance Interpretation <p> elements:
< P > This is my 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>.
Element contents are: This is my first paragraph.
<body> elements:
< Body > < P > This is my 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 > < Body > < P > This is my first paragraph. </ P > </ Body > </ HTML >
The
This element has a start tag
The element content is another HTML element (the BODY element).
Don't forget to end the tag
Even if you forget to use the end tag, most browsers will display HTML correctly:
< P > This is a paragraph < P > This is a paragraph
The above example is not a problem in most browsers, but do not rely on this approach. Forgetting to use the end tag can produce unpredictable results or errors.
Note: future HTML versions do not allow the end tag to be omitted.
An empty HTML element
HTML elements that have no content are called empty elements. The empty element is closed in the Start tab.
<br> is the empty element without closing the label (the <br> tag defines a newline).
In XHTML, XML, and future versions of HTML, all elements must be closed.
Adding slashes to the start tag, such as <br/>, is the correct way to close an empty element, which is accepted by HTML, XHTML, and XML.
Even if <br> is valid in all browsers, the use of <br/> is actually a longer term guarantee.
HTML Hint: Use lowercase tags
HTML tags are not case sensitive:<p> is equivalent to <p>. Many websites use uppercase HTML tags.
W3school uses lowercase tags because the World Wide Web Consortium recommends lowercase in HTML 4, and lowercase in future (X) HTML versions.
Learning content transfer from: http://www.w3school.com.cn/html/html_basic.asp
HTML Learning----------DAY2 Section Fourth