HTML nesting rules_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:48:10
Original
1394 people have browsed it

Reference:

HTML tag nesting rules - MOOC

HTML tag nesting rules - Blog Park

WEB standard series - HTML element nesting

block elements:

address, blockquote, center, dir, div, dl, dt, dd, fieldset, form, h1 ~h6, hr, isindex, menu, noframes, noscript, ol, p, pre, table, ul, etc.

Inline 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, etc.

Nesting rules:

  • Blocks can contain blocks and inlines, and inlines can only contain inlines
  • Block elements can contain inline elements or certain block elements, but inline elements cannot contain block elements. They can only contain other inline elements
  • Titles and paragraphs cannot contain blocks
  • There are several special block-level elements that can only contain inline elements and cannot contain block-level elements. These special tags are
  • h1, h2, h3, h4, h5, h6 , p, dt
  • Blocks and inline cannot be juxtaposed
  • Block-level elements are juxtaposed with block-level elements, and inline elements are juxtaposed with inline elements
  • Note:

    li is a block-level element and can nest block-level elements (including ul).

    Some tags have fixed nesting rules, such as ul contains li, ol contains li, dl contains dt and dd, etc.