How to Preview Your HTML Web Pages

Web browser icons on desktop
Alexander Hassenstein/Staff/Getty Images News/Getty Images

Many people don't realize that when you build a Web page on your computer, you don't have to post it to a Web server in order to view it. When you preview a Web page on your hard drive, all the browser-related functions (like JavaScript, CSS, and images) should work exactly as they would on your Web server. So testing your Web pages in Web browsers before you put it live is a good idea.

How to Test Your Files on Your Hard Drive

  1. Build your Web page and save it to your hard drive.
  1. Open your Web browser and go to the File menu and choose "Open".
  2. Browse to the file you saved on your hard drive.

Problems Testing

There are a few things that may go wrong when testing your Web pages on your hard drive rather than the Web server. Make sure that your pages are set up correctly for testing:

  • Use fully-qualified absolute paths for links. You can use page-relative paths for your links, but the best way to test links before a page is live is to use the full path to the page you're linking to. In other words, include the domain name in your links.
  • Use page-relative paths for your images. While you can use the full URL for your images, if the page you're testing is new, then chances are that your images aren't uploaded to the server any more than the HTML is. By using paths to images that are relative to the current page, they will show up when you test the file on your hard drive.
  • Check the paths to your CSS and JavaScript external files. There isn't a good rule of thumb for using full-path or relative-path URLs for scripts and CSS files - it depends upon your site and what works best for you. Instead, you should verify that whatever file you're pointing to has the most up-to-date information. For example, if you post to a full-path URL for your CSS, you'll need to upload that file to your server when you test.

    Be Sure to Test in Multiple Browsers

    Once you've browsed to your page in one browser, you can then copy the URL from the Location bar in the browser and paste it into other browsers on the same computer. When we build sites on our Windows machines, we test pages in the following browsers before uploading anything:

    • Internet Explorer
    • Opera
    • Firefox
    • Safari
    • Chrome

    Once you're sure the page looks right in the browsers you have on your hard drive, you can upload the page and test it again from the Web server. Once it's uploaded, you should connect to the page with other computers and operating systems or use a browser emulator like BrowserCam to do extensive testing.