1

I am a beginner in HTML. I'm self-learning.

Can we embed a HTML file to another HTML file?

I mean,how can I include a sub HTML page in broader main HTML? i.e have a chuck of HTML code referenced in my primary page without having too many HTML code which can be really messy.Quite similar to what you do with CSS.

Hope you understand the question? Thanks.

Ebite Zion
  • 340
  • 2
  • 10
Nanowatt
  • 33
  • 7

2 Answers2

0

In your html file: <a href="other-file.html">text to link</a>. You need to put this into the HTML file. It's not impossible to generate the relevant HTML using javascript or something, but best to learn this way first.

Check http://www.htmlhelp.com/ for tutorials and other information.

PaulProgrammer
  • 16,175
  • 4
  • 39
  • 56
  • 3
    That's not what he's asking for. He's asking how to do the html equivalent of `#include` in C. Duplicate: http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file – Daniel Martin Nov 16 '13 at 17:05
  • Oh. Well, in that case: server dependent. – PaulProgrammer Nov 16 '13 at 17:07
  • Hm, I wanted the big code to automatically appear in my main file when I run it without me having to click on it. I guess I just have to deal with tons of code lines :) thank you very much for your time anyway! – Nanowatt Nov 16 '13 at 17:10
  • You can include using javascript, to fetch and import HTML into the page, but I wouldn't recommend that for a variety of reasons, like it negatively affects search engine searches, and is sometimes difficult to make work correctly across browsers. – PaulProgrammer Nov 18 '13 at 02:20
0

Not possible unless you use a server-side language such as php include tag. Perhaps you can link it to another file using href but it's not possible to include the file using html unlike CSS or javascript.Hope that solves your question.

Joke_Sense10
  • 5,341
  • 2
  • 18
  • 22
  • Well I understand what you're saying, I'm just not a pro at this yet. But I'll take some time to learn it and I'll get there hopefully. Thanks for your help! – Nanowatt Nov 16 '13 at 17:14
  • As i said you can do it using php and you need not be a pro to do it..:)It's pretty simple.. – Joke_Sense10 Nov 16 '13 at 17:16