HTML HTML element basis ---

HTML documents are defined by the HTML element.

A, HTML elements

 

Element refers to all HTML tags from the tag start (start tag) to the end tag (end tag) of.

 

 

 

Start tag is often called an open-label (opening tag), the end tag is often called the closing tag (closing tag).

 

 Two, HTML element syntax

 

  • HTML element to start tag start
  • HTML elements with an end tag termination
  • The content of the element is content between the opening and closing tags
  • Some HTML elements have empty content (empty content)
  • Empty element to shut down at the start tag (tag beginning to end and end)
  • Most HTML elements can have attributes

 

 Third, nested HTML elements

 

Most HTML elements can be nested (can contain other HTML elements).

HTML document consists of nested HTML elements.

HTML document instance

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

The example above contains three HTML elements.

 

Four, HTML examples to explain

 

1. <p> element:

<p>This is my first paragraph.</p>

 

The <p> element defines a paragraph in the HTML document.

This element has a start tag <p>, and a closing tag </ p>.

Element content is: This is my first paragraph.

 

2. <body> element:

 

<body>
<p>This is my first paragraph.</p>
</body>

 

<Body> element defines the body of the HTML document.

This element has a start tag <body>, and an end tag </ body>.

Element content is another HTML element (p element).

3. <html> element:

 

<html>

<body>
<p>This is my first paragraph.</p>
</body>

</html>

 

<Html> element defines the whole HTML document.

This element has a start tag <html>, and an end tag </ html>.

HTNL element content is another element (body element).

 

Fifth, do not forget the end tag

 

Even if you forget the end tag, most browsers will correctly display HTML:

<p>This is a paragraph
<p>This is another paragraph

 

In the example above, most browsers no problem, but do not rely on this practice. Forgetting the end tag can produce unexpected results or errors.

Note: Future versions of HTML allow you to skip end tags.

 

Six empty HTML elements

 

HTML elements without content are called empty elements. Empty elements are closed in the start tag.

<br> is no closing tag empty element (<br> tag defines a line break)

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

Adding a slash at the beginning of the label, such as <br />, is the proper way to close empty elements, HTML, XHTML and XML accept this way.

Even <br> are valid in all browsers, but using <br /> actually more long-term protection.

 

Seven, HTML Tip: Use lowercase tags

 

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

World Wide Web Consortium (W3C) HTML 4 in the recommended use lower case, and in the next version of HTML (X) is forced to use lower case.

Guess you like

Origin www.cnblogs.com/Tomorrow-will-be-better/p/11129894.html