Is using the h2 tag semantically correct inside a summary tag?

I am not sure if it is correct to have the <h2> tag inside the <summary> .

Is it possible to semantically have an <h2> or <h1> tag inside a <summary> ?

+5
source share
2 answers

The semantics will depend on the specific content and context in which it is located.

In terms of reality, the specification says:

Content Model :
Or: the wording of the content.
Or: one header content element.

So this is true as long as you have nothing else.

+4
source

Of course, this is allowed. But you need to style CSS a bit to avoid wrapping. To test aviabillity, use W3-Validator and use W3Schools .

 <!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> 
0
source

Source: https://habr.com/ru/post/1261518/


All Articles