Wu Yuxiong - born nature study notes HTML: HTML elements

HTML documents are defined by HTML elements. 

HTML element 
start tag end tag element content * * 
< P >     This is a paragraph     </ P > 
< A the href = "Default.htm" >     This is a link     </ A > 
< br >     wrap      
* start tag is often referred start tag (opening tag), often called a closed end tag label (closing tag).
HTML syntax elements 
HTML element start tag to start 
HTML tag elements in order to terminate the end of 
the element content is content between the opening and closing tags 
certain HTML element has an empty content (empty content) 
empty elements off start tag (in end of the beginning and end tags) 
most HTML elements can have attributes
Nested HTML elements 
HTML document consists of nested HTML elements. 

HTML document instance 
<! DOCTYPE HTML > 
< HTML > 

< body > 
< the p- > This is the first paragraph. </ P > 
</ body > 

</ HTML > 
The above examples containing three HTML elements.
Examples of parsing HTML
 < P > element: 

< P > This is the first paragraph. </ P > 
This < P > element defines a passage HTML document. 
This element has a start tag < the p- > and an end tag </ the p- > . 
Element content is: This is the first paragraph. 

< Body > element: 

< body > 
< P > This is the first paragraph. </ The p- > 
</ body > 
< body > element defines the body of the HTML document. 
This element has a start tag <> And an end tag </ body > . 
Element content is another HTML element (p element). 

< HTML > element: 

< HTML > 

< body > 
< P > This is the first paragraph. </ The p- > 
</ body > 

</ HTML > 
< HTML > element defines the whole HTML document. 
This element has a start tag < HTML > , and an end tag </ HTML > . 
Element content is another HTML element (body element).
Do not forget the end tag 
even if you forget the end tag, most browsers will display HTML correctly: 

< the p- > This is a paragraph
 < the p- > This is a paragraph 
above examples can also be displayed properly in the browser, due to the closure tags are optional. 

But do not rely on this practice. Forgetting the end tag can produce unexpected results or errors.
HTML empty element 
has no content of HTML elements are called empty elements. Empty elements are closed in the start tag. 

< Br > is not empty element closing tag ( < br > tag defines a line). 

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

Slash in the start tag, such as < br /> , an empty element is off the proper way, HTML, XHTML and XML accepted this way. 

Even < br > are valid in all browsers, but using < br /> in fact, it is more long-term protection.
HTML Tip: Use lowercase tags

 

Guess you like

Origin www.cnblogs.com/tszr/p/11986377.html