简体   繁体   中英

DOCTYPE necessary for HTML includes?

I'm working on a new web application that has a common footer included on all pages. What I'm wondering is if it is necessary or if there is any benefit at all to having the footer file include HTML, HEAD and BODY tags as shown below?

Is this good or bad practice? To me it seems to just bloat the code.

<html>
    <head>
        ... common js and css files
    </head>
    <body>
        ... html for the current page

        <!-- Footer -->
        <html>
            <head></head>
            <body>
                ... legal information
            </body>
        </html>
    </body>
</html>

No, there should only be one html and body tag in a html document unless it's contained within another iframe.

A standard compliant html document would contain the following structure:

<html>
    <head>
        ... common js and css files
    </head>
    <body>
        <div>   
        ... html for the current page
        </div>
        <!-- Footer -->
        <div>
                ... legal information
        </div>
    </body>
</html>

不,该标记是错误的,在页脚中,您仅应包含与页脚相关的代码。

No, your common include should just contain the HTML for that specific piece of the page. The master template should include tags such as html, head, body.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM