0

I have a bunch of link tags in the tag of my HTML document. Is there any way I can put all of this in a separate HTML document and just link to that one?

E.g turn this:

</head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href='http://fonts.googleapis.com/css?family=Arvo:700' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Roboto:300' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="styles.css">
    <script src="scripts.js"></script>
    <title>Home</title>
</head>

Into this:

<head>
    <link href="head.html" type="text/html">
    <title>Home</title>
</head>

With the separate file head.html containing all those links?

user2397282
  • 3,610
  • 15
  • 43
  • 91

2 Answers2

0

You can include all your stylesheets in one stylesheet with the include method like follows:

CSS:

include 'http://fonts.googleapis.com/css?family=Arvo:700'
include 'http://fonts.googleapis.com/css?family=Lato:300'
include 'http://fonts.googleapis.com/css?family=Roboto:300'

and then link just the main CSS file.

Florin Pop
  • 4,959
  • 3
  • 21
  • 54
-1

The short answer is frames. That is if you want to use 'html' only. Yet frames are bad practice tbh, specially for this.

You can do the 'include' with Jquery too:

<script> 
$(function(){
  $("#yourdiv").load("includefile.html"); 
});
</script> 

An other way is to include with PHP

http://php.net/manual/en/function.include.php

W van Rij
  • 530
  • 2
  • 16