In HTML, what does nesting mean exactly? Is there a specification which defines the term?
For example, some sources state that merely placing any element in another is nesting:
<div>Thee is a span <span>nested</span> in this div</div>
Other sources say that they must be elements of the same type:
<span>There is a span <span>nested</span> in another span</span>
Still other sources suggest that it is nested only if the elements is the only immediate child:
<span><span>nested</span></span>
Is there a formal definition, or is “nesting” more of a casual term? Is it related to the definition of HTML or the specifications?
It is a casual and context sensitive term.
Generally, “Nested foos” means “Having a foo that is a (not necessarily direct) descendent of another foo”. In a context where it isn’t one specific thing being nested, it usually just means “inside but at any depth”