I've been wondering this for a while, because I've got some pretty deep HTML structure开发者_运维问答s going on. My points are these:
- Is there a maximum limit to the number of nesting levels for HTML?
- Likewise with CSS - I need to select stuff from the leaf nodes of the HTML DOM tree?
- Is it browser dependent?
Thanks for any help,
James
I'm going to lean toward no limit that I'm aware of. You should check this one out: http://www.geeksaresexy.net/2009/09/01/a-hidden-gem-in-html/. The site is nested deeply enough to recreate a skyline using font tags.
Neither the XHTML 1.0 nor the HTML 4.01 specification defines a nesting limitation. HTML5 is not yet standardized, but the working spec does not reference a limitation.
The CSS 2 spec similarly contains no limit.
Browser-based limitations may be an issue in the future, but I was unable to find any problem reports with modern browsers.
I think you'll hit memory limitations before you hit any DOM restrictions (if any exist; I believe they don't).
精彩评论