Is it semantically correct to use h2 tag inside summary tag?

2.9k views Asked by At

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?

2

There are 2 answers

0
Quentin On BEST ANSWER

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.

2
Htaccess24 On

Sure, it is allowed. But you have to style a bit with CSS to avoid wrapping. To test the aviabillity use the W3-Validator and use the W3Schools as well.

<!DOCTYPE html>
<html>
<head>
    <title>HTML Summary usage</title>
</head>
<body>
  <details>
    <summary><h1>Copyright 1999-2014.</h1></summary>
    <p> - by Refsnes Data. All Rights Reserved.</p>
    <p>All content and graphics on this web site are the property of the company Refsnes Data.</p>
  </details>

  <p><b>Note:</b> The summary element is not supported in Edge/Internet Explorer.</p>
</body>
</html>