"common" HTML import file

Discussion in 'HTML' started by Hortich, May 22, 2005.

  1. Hortich

    Hortich Guest

    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>
     
    Hortich, May 22, 2005
    #1
    1. Advertising

  2. Hortich wrote:

    > 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
    have a <title> element in the <head>, and content (such as <div> elements)
    may go only in the <body>.

    > 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

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, May 22, 2005
    #2
    1. Advertising

  3. Hortich

    Spartanicus Guest

    "Hortich" <> wrote:

    >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.

    --
    Spartanicus
     
    Spartanicus, May 22, 2005
    #3
  4. Hortich

    Si Guest

    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
     
    Si, May 22, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    986
    Paul Opal
    Oct 11, 2004
  2. MK
    Replies:
    6
    Views:
    714
    noSpAm0000
    May 16, 2005
  3. Denny
    Replies:
    1
    Views:
    810
  4. John Reye
    Replies:
    28
    Views:
    1,406
    Tim Rentsch
    May 8, 2012
  5. Jason Mellone
    Replies:
    3
    Views:
    130
    Jurko Gospodnetić
    May 7, 2014
Loading...

Share This Page