"common" HTML import file

H

Hortich

Hi, I am new to HTML but not to programming. I have a simple HTML question.
I am going to be verbose as I want you to understand my problem (rather than
just asking how to do something).

I have pasted the contents of my file "one.htm" below. I also have files
"two.htm", "three.htm", and "four.htm". In all these files, the section

<head>
<style type="text/css">
@import "myCSS.css";
</style>

<div class="s1">
<p><a href="one.htm">One</a></p>
<p><a href="two.htm">Two</a></p>
<p><a href="three.htm">Three</a></p>
<p><a href="four.htm">Four</a></p>
</div>
</head>

is identical. The rest of the file content is very different. I would like
to "import" somehow this same text from a file into each of my HTML pages.
The reason I want to do this is because in my real HTML pages, I have 36
pages and I don't want to change each one of them each time I want to add a
new page (eg "<p><a href="five.htm">Five</a></p>" in the above example). I
think I want to take the code above and put it in a file called
"common.htm", then in each of my 36 other HTML pages I want to say something
like @import "common.htm". I then change my file "common.htm" once and all
the changes are replicated in all 36 other pages. I am not sure how to do
this, or if it can be done, but I am sure I do not want to go down the
"frames" route.

I would really appreciate some guidance here, or just the basic vocab to use
so I can google out the information.

Thank you

Hortich


Here is the content on "one.htm".



<html>

<head>
<style type="text/css">
@import "myCSS.css";
</style>

<div class="s1">
<p><a href="one.htm">One</a></p>
<p><a href="two.htm">Two</a></p>
<p><a href="three.htm">Three</a></p>
<p><a href="four.htm">Four</a></p>
</div>
</head>

<body>
<div class="s2">
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
this is the body in the html page for one.htm.
</div>
<body>

</html>
 
D

David Dorward

Hortich said:
I have pasted the contents of my file "one.htm" below. I also have files
"two.htm", "three.htm", and "four.htm". In all these files, the section

<snip>

You should pay a visit to http://validator.w3.org/. All HTML documents must
and content (such as <div> elements) said:
is identical. The rest of the file content is very different. I would like
to "import" somehow this same text from a file into each of my HTML pages.

http://www.allmyfaqs.com/faq.pl?Include_one_file_in_another
 
S

Spartanicus

Hortich said:
I am new to HTML but not to programming.

HTML is a markup language, nothing to do with programming.
<div class="s1">
<p><a href="one.htm">One</a></p>
<p><a href="two.htm">Two</a></p>
<p><a href="three.htm">Three</a></p>
<p><a href="four.htm">Four</a></p>
</div>

That's a list of links, not paragraphs, mark them up appropriately.
 
S

Si

Hortich wrote:

snip
I
think I want to take the code above and put it in a file called
"common.htm", then in each of my 36 other HTML pages I want to say something
like @import "common.htm". I then change my file "common.htm" once and all
the changes are replicated in all 36 other pages.

If you server supports include files and most do, you can rename your
html to shtml or asp etc then use the include virtual or file to include
your common.htm file. Use the include in place of your code.

The syntax is as follows

<!--#include virtual="/common.htm"--> for absolute paths

or

<!--#include file="common.htm"--> for relative paths.

HTH, Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top