I am not sure whether is it correct to have <h2>
tag inside <summary>
tag.
Whether semantically it is valid to have <h2>
or <h1>
tag inside <summary>
tag?
The semantics would depend on the specific content you had and the context it appears in.
From a validity point of view, the spec says:
Content model:
Phrasing content, optionally intermixed with heading content.
So, it is valid.