www.webdeveloper.com
Results 1 to 8 of 8

Thread: External File of HTML Code

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    External File of HTML Code

    Is there a way to have a block of html code, stored in an external file, included in multiple html pages, but where you only have to edit/update it in one location?
    I know in php they have 'include', so you have an external file that has code in it, then on each page you want that code you simply state to include it. And to update the code, you only have to update the single file. Is there anything similar to that in html or CSS?

    Thanks

  2. #2
    Join Date
    Jan 2011
    Posts
    5
    I decided Javascript external files was the best approach for me.

  3. #3
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Quote Originally Posted by svenjoypro View Post
    I decided Javascript external files was the best approach for me.
    There are several ways to do this--and the JavaScript method is absolutely the worst. Do you have any server side scripting available? PHP? SSI?
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  4. #4
    Join Date
    Jan 2011
    Posts
    5
    I could probably do php, the problem with that is I have to set up a testing server; but I know about WAMP. And I have no idea what SSI is.
    Why do you say javascript is the worst?
    And how do most websites update their code? Surely they don't go through each page one by one cutting and pasting the new updated code in.

  5. #5
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    Most websites use PHP, a few SSI ( http://en.wikipedia.org/wiki/Server_Side_Includes ). The JavaScript method is bad because JavaScript tends to not work. It'll work for you--so you will think that there is no problem--but not for me and not for search engines.
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  6. #6
    Join Date
    Jan 2011
    Posts
    5
    But php include works for search engines? And is common?

    About how much do they use from external files? Currently I'm thinking of having my top menus, and my bottom footer (2 seperate files).

    I'm a noob at most of this stuff. I made my first page 10 or so years ago on geocities, and have played around with stuff off and on. And updating every single page just seems pointless. But apparently it's common to use php. That's good to know. Thanks for all your advice Charles.

  7. #7
    Join Date
    Aug 2006
    Posts
    1,897
    Updating every page *is* pointless, and PHP is the right way to go. It's quite common to use it for navigation, headers, and footers, and even other reusable chunks of code that might be in various places in the body of a page.

    Dave

  8. #8
    Join Date
    Jan 2011
    Posts
    5
    Awesome, thanks tracknut

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles