-2

I'm adding my code below. I am working on a php webpage, but for some reason elements that I have in the <head> are showing up in the <body> instead. I don't understand why this is but it's also messing up my styles.

Could i get a clear explanation of the use of the tag in PHP/HTML in order to better understand how styles in my css sheet relates to them?

TwoEyedDan
  • 152
  • 1
  • 12
  • 11
    You seem to have misunderstood the concept of the page head and body. – BoltClock May 03 '13 at 19:00
  • 6
    is not for displaying items, it is to declare scripts, link to css file, and so on. Not to display the content of your page. – Jeremy D May 03 '13 at 19:00
  • `` is like a header, but it defines metadata for a page, it's not like "table header" or "page header". – Marc B May 03 '13 at 19:13
  • Wow. Also, why are there so many `` tags? Everything you want displayed belongs in the body. –  May 03 '13 at 19:15
  • 1
    Lets not go crazy on him like everyone wants to... Lets just refer him to a good book or two and move on. I learned everything I know through hands-on experience so I don't have any. –  May 03 '13 at 19:22
  • @TwoEyedDan -- you can only select **one** answer to be "accepted" – Naftali Jun 21 '13 at 13:38

4 Answers4

4

Document elements cannot be in the head of the page, so most browsers nowadays automatically put the elements in the body.

Naftali
  • 144,921
  • 39
  • 244
  • 303
0

You're inserting invalid elements into the <head>. There are only certain types of elements that can be in the <head>:

<title>, <base>, <link>, <style>, <meta>, <script>, <noscript>, <command>

The browser is trying to correct your invalid HTML by moving the invalid elements to the body.

jmoerdyk
  • 5,544
  • 7
  • 38
  • 49
0

You definitely don't understand the entire concept of HTML.

That being said, it isn't a bad thing to not understand. None of us have known since we were born.

You need to completely re-learn (Or learn in the first place) everything you know for sure. You don't just need a simple answer on here about how the <head> and <body work, you need a book or two.

Then, when you have read up on HTML you should come back with questions. Don't ask us things you should be learning on your own first. Do the ground work yourself.

Best of luck.

0

To me, it looks like you're using <head></head> as your navigation and <body></body> as your page's content. It should look something more like this:

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>Your Title</title>
  </head>
  <body>
    <header>
      Your header content (navigation) goes here
    </header>

    <div id="page">
      Your page content goes here
    </div>

    <footer>
      Your footer content goes here
    </footer>
  </body>
</html>

Where <header></header> is your page's navigation and <div id="page"></div> is your page's content.

The <head></head> tag will not be displayed on your webpage. It works to declare information or include information.

The <body></body> tag is what tells the browser what to display. The HTML within this will be processed and displayed. All of your structural HTML and content goes here. Its not used as a structural element, it is a declarative. Use <header>, <div>, <footer>, and even table for structure (though you shouldn't). There are also other elements you can use by reading up on them.

Community
  • 1
  • 1
Jeremy
  • 310
  • 1
  • 5
  • 18