sodcalculator

10 Tech How-To

Archive a Webpage with Images and CSS

Guide 10-60743 · Updated · Step by step

This guide shows you how to save a complete webpage—including its images, CSS, and JavaScript—so you can view it offline exactly as it appeared online. You’ll learn two reliable methods: using your browser’s built-in “Save As” feature (for quick captures) and using a command-line tool like wget (for bulk or automated archiving). No special software is required for the first method; the second requires a terminal and, on Windows, a small install.

What You’ll Need

  • A web browser (Chrome, Firefox, Edge, or Safari)
  • For the wget method: a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and wget installed (see Troubleshooting if it’s missing).

Step-by-Step

Method 1: Browser “Save Page As” (Easiest)

  1. Open the webpage you want to archive in your browser.
  2. Press Ctrl+S (Windows/Linux) or Cmd+S (Mac) to open the Save dialog. Alternatively, right-click anywhere on the page and select Save As (or Save Page As in some browsers).
  3. In the dialog, choose a folder where you want to save the page.
  4. Set the Format (or Save as type) to “Webpage, Complete” (Chrome/Edge), “Webpage, HTML Only” plus a separate folder for resources (Firefox), or “Page Source” (Safari). For the most complete capture, choose “Webpage, Complete” if available—it creates an HTML file and a folder containing all images, CSS, and scripts.
  5. Click Save. The browser downloads the HTML file and a folder with the same name (e.g., example.html and example_files/).
  6. To view the archive, double-click the HTML file. It should render with images and styling, even without an internet connection.

Method 2: wget (Command Line, More Control)

  1. Open a terminal (Command Prompt, PowerShell, or Terminal).
  2. Navigate to the directory where you want to save the archive: cd /path/to/your/folder.
  3. Run the following command, replacing https://example.com/page with the actual URL:
    wget -p -k -E -np -e robots=off https://example.com/page
    • -p (or --page-requisites) downloads all images, CSS, and JavaScript needed to display the page.
    • -k (or --convert-links) rewrites links in the HTML so they point to local files, making the page work offline.
    • -E (or --adjust-extension) adds .html extension to saved files that lack it.
    • -np (or --no-parent) prevents wget from going up to the parent directory, keeping the archive self-contained.
    • -e robots=off ignores robots.txt restrictions (use with caution and respect website terms).
  4. Press Enter. wget will download the page and all its resources into the current folder, creating a mirror of the page.
  5. Open the downloaded HTML file in a browser to verify it works offline.

Common Mistakes

  • Saving as “HTML Only”—this saves just the text and structure, but no images or styling. The page will look plain and broken.
  • Moving the HTML file without its accompanying folder—if you move the .html file to another location, the browser won’t find the linked resources. Keep the HTML and the folder together.
  • Using wget without -p—you’ll get only the HTML, not the images or CSS.
  • Forgetting -k—links will still point to the original online URLs, so the page won’t display correctly offline.
  • Archiving a page that requires login—the saved version may not show content that is behind a login or session.

Tips

  • For a single page, the browser method is usually sufficient and faster.
  • For archiving an entire website or a page with many resources, wget is more reliable and gives you control over recursion and depth.
  • Check the saved page after archiving—scroll, click a few links, and verify images load. Some dynamic content (e.g., videos, live feeds) may not be captured.
  • If you need a timestamped archive for legal or reference purposes, consider using a web archiving service like the Wayback Machine, which handles this automatically.
  • If a page uses heavy JavaScript to load content, try saving after the page has fully loaded, or use a browser extension that captures rendered pages (e.g., SingleFile).

Troubleshooting

  • Images or CSS missing after saving: This usually happens if you chose “HTML Only” or if the page uses dynamic loading. Re-save using “Webpage, Complete” or use wget with -p and -k.
  • wget not recognized as a command: On Windows, download wget from the official GNU project or use a package manager like Chocolatey (choco install wget). On macOS, wget is not preinstalled; install via Homebrew (brew install wget) or use curl as an alternative (though curl doesn’t handle page requisites as well). On Linux, install via your package manager (e.g., sudo apt install wget).
  • The saved page looks different from online: Some sites use responsive design that changes based on viewport; the saved version may default to a mobile layout. Try resizing the browser window or using a user-agent string with wget (e.g., -U "Mozilla/5.0").
  • wget downloads a lot of unwanted files: Use -l 1 to limit recursion to one level, or add -A html,css,js,jpg,png,gif,svg to restrict file types.
  • Page requires cookies or session: Use wget with --load-cookies cookies.txt after exporting cookies from your browser, or use a browser extension that saves pages with session data.

Frequently Asked Questions

Can I archive a webpage that requires a login?

Yes, but you’ll need to have an active session. In the browser, you can save the page while logged in. With wget, you can supply cookies using --load-cookies after exporting them from your browser. However, some sites may block archiving or the saved page may not work without a valid session.

Will the archived page work on any device?

Generally yes, as long as you open the HTML file in a modern browser. The resources are local, so it should work offline. However, if the page uses web fonts or external APIs, those may not be captured.

How do I archive a whole website, not just one page?

Use wget with the -r (recursive) flag and limit the depth with -l (e.g., -l 2 for two levels). Be careful: recursive downloads can create huge archives and may strain the server. Always respect robots.txt and terms of service.

Why does the saved page have a folder with the same name?

That folder contains all the resources (images, CSS, JavaScript) that the HTML file references. It’s created automatically when you choose “Webpage, Complete”. Keep the folder and the HTML file together, or the page will break.

Can I archive a page without installing anything?

Yes, the browser’s “Save Page As” feature is built-in and requires no installation. For more advanced needs, you could also use online services like the Wayback Machine, but they don’t give you a local copy.

What about pages with embedded videos or audio?

Videos and audio are often served from external CDNs and may not be captured by standard archiving. You might need to download the media separately using tools like yt-dlp or browser extensions. The HTML will still contain the player, but the media source may be missing.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →