Search code examples
htmlcssstylesheet

Putting all <link rel="stylesheet" or "import" to another html file


Hello i want to know if is this possible and if it is how to make it I have some imports and some stylesheet links and script in my main index.php is it possible to put them to another file with name import.html and load just this file instead of bunch of other links?

Thank for your help.


Solution

  • You can try doing it like this:

    <html>
      <head>
          <?php include head.html; ?>  
      </head>
      <body>
      </body>
    </html>
    

    The HTML in head.html contains your info. It will appear as if it is in the actual index.php script.

    Edit: As mentioned in an another answer, I am not sure of the benefit of this (other than cleaner clode maybe? keeping things modularized?), but since you asked how to do it, this is how.