htmlcross-browserweb-standardsstability

How many nested tags in HTML can you have before it crashes a browser?


I had a thought earlier today regarding nested HTML tags and how browsers render them:

<html xmlns="http://www.w3.org/1999/xhtml" {or whichever html version} xml:lang="en" lang="en">
<head>
</head>
<body>

let n = 1

<div>

recurse div n times until maximum (browser fails)

</div>
</body>
</html>

what will n be when the browser cannot handle any more recursion?

I would think this would be different for each browser, and different also for mobile apps. Is there a web standard, such as the maximum 127 character length for domain names?

I have never run into this problem, but I am curious when it would.


Solution

  • There is no standard requiring a maximum nesting, so this will be entirely implementation specific.

    Chances are that before crashing, the browser would become unusable (slow downs etc).

    If you are very curious, you can benchmark this - code an application that generates nested tags and see when each browser crashes on you :)