Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 753
Nitish Avatar asked Dec 19 '16 17:12

Nitish


2 Answers

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.

like image 63
Quentin Avatar answered Nov 06 '22 01:11

Quentin


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>
like image 29
Htaccess24 Avatar answered Nov 06 '22 01:11

Htaccess24