0

Is is possible to import contents from one html file into another by using just plain HTML or CSS? JavaScript or jQuery is NOT an option, I want to be able import contents of a file if JavaScript is disabled

Guy Lee
  • 193
  • 1
  • 10
  • Possible duplicate of [Include another HTML file in a HTML file](http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file) – Zac Webb May 11 '17 at 23:18
  • 3
    not possible. if JS is disabled, you can look into using PHP – JJJ May 11 '17 at 23:18
  • If HTML is rendered on the server, use server-side code to do it is simple. – noob May 12 '17 at 04:42
  • For a bit of context, please briefly explain why you want to import HTML or a brief outline of what you are hoping to achieve. For example, are you wanting to put common elements like a Nav bar in one file? – Jon P May 12 '17 at 04:44
  • 1
    @noob, careful with the term "rendered", it can be ambiguous here... you could be referring to server side code generating HTML **or** the browser "rendering" the HTML and CSS to visual (or audio if using a screen reader) elements. – Jon P May 12 '17 at 04:47
  • @JonP is right. I should say *generate HTML* – noob May 12 '17 at 05:04

2 Answers2

0

Checkout HTML5 imports via Html5rocks tutorial and at polymer-project

For example:

<head>
  <link rel="import" href="/path/to/imports/stuff.html">
</head>
comunit
  • 86
  • 1
  • 5
  • I'm pretty sure I need to use JavaScript to import the contents of the imported file. I'm trying to figure it out without using JavaScript or jQuery – Guy Lee May 11 '17 at 23:26
0

Your best bet is to render the HTML server side, ie, via PHP or server side JS. Since most server readily supports PHP, you can simply change both your HTML file extension to .php and insert a php include tag. (Include PHP file into HTML file).

Community
  • 1
  • 1