There are many XHTML tags: div, ul, Li, DL, DT, DD, H1~H6, p, a, Addressa, span, strong ... When we use these tags to build the page structure, it is possible to embed them infinitely, but, nested also need to have certain rules, can not be arbitrarily nested by their own personal habits, then the HTML tag nested rules?
First, HTML tags include block-level elements (blocks), inline elements (inline)
1, block-level elements
Generally used to build Web site architecture, layout, hosting content ... It includes the following tags:
Address, blockquote, center, dir, Div, DL, DT, DD, fieldset, form, H1~h6, HR, Isindex, menu, Noframes, NoScript, OL, p, pre, Table, UL
2. Embedded elements
Some of the details or parts of the site are generally used to "emphasize, differentiate style, superscript, subscript, anchor" and so on, these tags are embedded elements:
A, ABBR, acronym, B, BDO, big, BR, cite, code, DFN, EM, font, I, IMG, input, KBD, label, Q, S, Samp, select, small, span, strike, Strong, Sub, SUP, textarea, TT, U, var
Ii. nested rules for HTML tags
1. Block elements can contain inline elements or some block elements, but inline elements cannot contain block elements, which can contain only other inline elements:
<div>
<a href= "#" ><span></span></a>--to
<span><div></div></span>--wrong
2. Block-level elements cannot be placed in <p>:
<p><ol><li></li></ol></p>--wrong
<p><div></div></p>--wrong
3. There are several special block-level elements that can contain only inline elements and no longer contain block-level elements, which are the following special tags:
H1, H2, H3, H4, H5, H6, p, DT
4. Li can contain div tags-this one is not necessarily listed separately, but many people on the internet have some doubts about it, here slightly explain:
Li and div tags are loaded contents of the container, equal status, no level of points (for example: H1, H2 such a hierarchical system ^_^), you know, Li Tag even its parent UL or OL can be accommodated, why would someone think that Li will not fit a div? Do not see Li so stingy, don't look at Li is very thin, in fact, Li's mind is very big drop ...
5. Block-level elements are tied to block-level elements, inline elements and inline elements:
<div>
<div><a href= "#" ></a><span></span></div>--to
<div>
Super simple but don't know: nested rules for HTML tags