質問

When creating an html document my code works either way, but how do others like to organize their html hierarchy? for example I like to put my site's banner and the navigation bar in <head>.

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="style.css" />
        <script type='text/javascript' src='script.js'></script>

        <title> User's Profile'</title>

        <div id="header">
            <img src="http://svc004.bookeasy.com/images/MARGS/flourish-website-banner3.jpg" />
        </div>

        <div id="toolbar">
            <span>Username</span>
            <p>Profile</p>
            <p>Medals</p>
            <p>Account Settings</p>
            <p>logout</p>
        </div>

    </head>
    <body>

        <div id="left_nav">
            <p>Home</p>
            <p>Scout</p>
            <p>Attack</p>
            <p>Fourms</p>
            <p>Contact</p>
        </div>
    </body>
</html>
役に立ちましたか?

解決 2

The spec says that the <head> element has to contain:

One or more elements of metadata content, of which exactly one is a title element.

Further down:

Metadata content is content that sets up the presentation or behavior of the rest of the content, or that sets up the relationship of the document with other documents, or that conveys other "out of band" information.

You can only put these tags in there:

  • <base>
  • <link>
  • <meta>
  • <noscript>
  • <script>
  • <style>
  • <title>

The way you're doing it isn't good. Put the header in a <header> element in the <body>.

他のヒント

You shouldn't put anything in your head that you want to display as en element, because it's not the correct element for it.

It may work but you never know when it may not (or have subtle bugs). It will also confuse anyone who has to maintain this markup after you.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top