HTML block elements and inline elements nested rule

There are many types of HTML tags, some tags below to allow only specific tags exist, this is called a nested HTML rules.
Do not follow the rules of writing nested HTML, the browser will not parse correctly, will not comply with the rules of the nodes nested into the following target node, or become plain text.
About HTML nested rules, we must grasp the difference between block elements and inline elements.

Block elements:

    Container generally other elements, can accommodate bulk inline elements and other elements, the exclusion of other elements therewith block elements on the same row, the width (width) height (height) function. Common div and p block elements

Inline elements:

    Inline elements can only receive text or other inline elements, which allows other elements associated therewith within the same row, but the width (width) height (height) does not work. Common inline elements is a.

Block elements and inline elements nested rule:

(1) The block elements can contain some inline elements or block elements, but can not contain inline elements block elements, it can contain other inline elements

Example:
  <div> <h1 of> </ h1 of> <P> </ P> </ div>
  <a href="#"> <span> </ span> </a>
. (2) can not block-level element on the p elements inside

Example:

  <P> <OL> <Li> </ Li> </ OL> </ P> <P> <div> </ div> </ P>
(. 3). There are several special block-level element only advocated contain inline element can not contain block elements, these special label is:

  h1 of, H2, H3, H4, H5, H6, P, dt
(. 4) may comprise div tag label .li

Example:
  <Li> <div> </ div> </ Li>
. (. 5) and the block-level elements block elements in parallel, inline elements juxtaposed with the inline element

例:
  <div><h2></h2><p></p></div>
  <div><a href="#"></a><span></span></div>

 

Guess you like

Origin www.cnblogs.com/jing-tian/p/11076400.html