In HTML5, can the
and
tags appear outside of the <body> tag?

后端 未结 8 1480
梦谈多话
梦谈多话 2020-12-01 07:12

I\'m currently using the above tags in this way (classic tag order):


  ...
  
    
...
8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 07:47

    I see what you are trying to do, you are trying to use the tag as the container for the main content of the page. Instead, use the

    tag, as specified in the HTML5 spec. I use this layout:

        
        
             *Metadata* 
            
                
    *

    and other important stuff

    *
    *All my content*
    *Copyright, links, social media etc*

    I'm not 100% sure but I think that anything outside the tag is considered metadata and will not be rendered by the browser. I don't think that the DOM can access it either.

    To conclude, use the

    tag for your content and keep formatting your HTML the correct way as you have in your first code snippet. You used the
    tag but I think that comes with some weird formatting issues when you try to apply CSS.

提交回复
热议问题