php - How to properly include a header file in a webpage -


so have header file:

<html> <head>    <link href="/design_header.css" rel="stylesheet" type="text/css" /> </head> <body>    content </body> </html> 

and want place header in file

  <!doctype html>     <html xmlns="http://www.w3.org/1999/xhtml" lang="en">      <head>      meta tags etc.     </head>     <body>        <div id="container_big">        <?php include 'header_login.php'; ?>         content       </div>     </body>     </html> 

the problem have regular <html>, <head>, <body> tags inside <body> tag of webpage. in html validator receive errors like

stray start tag html. stray end tag head. body start tag seen element of th 

e same type open.

how properly? btw. place footer bottom of webpage same way.

your header file should contain html text want header. inserted webpage, should not full html document.

having html header in header

one option instead include in header file html header (used pages include it). has downside not following recommendation have css loading before rendered.

see: https://stackoverflow.com/a/1642259/1688441

header file

 <link href="/design_header.css" rel="stylesheet" type="text/css" />  content 

other files

  <!doctype html>     <html xmlns="http://www.w3.org/1999/xhtml" lang="en">      <head>      meta tags etc.     </head>     <body>        <div id="container_big">        <?php include 'header_login.php'; ?>         content       </div>     </body>     </html> 

having html header in headerfile , separate headfile

you have have separate global_head_include.html (or txt, php, etc) file , put css code there.

header file (for include)

 header content 

file css includes (for include)

  <link href="/design_header.css" rel="stylesheet" type="text/css" /> whatever else global... 

other files

  <!doctype html>     <html xmlns="http://www.w3.org/1999/xhtml" lang="en">      <head>      meta tags etc.       <?php include 'global_head_include.php'; ?>     </head>     <body>        <div id="container_big">        <?php include 'header_login.php'; ?>         content       </div>     </body>     </html> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -