Home >Web Front-end >HTML Tutorial >HTML nesting rules_html/css_WEB-ITnose
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:
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.
Let me explain here, although you can use display to set block and inline, it is obviously not rigorous to define the nesting relationship. (I wonder if search engines will crawl CSS content?)
Advanced knowledge
WEB Standard Series-HTML Element Nesting
Since I don’t have access to HTML5 now, I will keep
Problems that may be caused by nesting errors
element will cause parsing errors in all browsers
Actually, it is not very reasonable to say parsing errors here. It should mean that the results parsed by the browser are inconsistent with the results we expect, but Any nested errors will not cause significant differences in page rendering. Big mistake.
Finally:
Although we can nest tags, in order To improve browser rendering efficiency, we should minimize nested tags and flatten them. < li > " >< div > div > a > h4 > li >
ul >The above code comes from Facebook, and I instantly felt so awesome! Ha ha.