← Community home

When does download suggest saving a resource?

Community › Forums › Links & Navigation › When does download suggest saving a resource?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #180

    A downloadable HTML example opens in a tab instead of saving.

    #181

    Detailed answer

    The download attribute expresses an intent to download the destination and can suggest a filename.

    Actual behavior depends on the origin, browser, and server headers. For files you control, configure the response appropriately and test it. Do not assume the attribute overrides any third-party server's behavior.

    Example

    <a href="/examples/hello.html" download="hello.html">Download HTML example</a>

    Understanding the behavior

    Download expresses an intention to save a resource and can suggest a filename. Browser behavior depends on the URL's origin, headers and other restrictions. It is not a way to force every third-party URL to download.

    Practical implementation notes

    Test the served file response and Content-Disposition when downloads matter. The linked asset should have an accurate type and a clear filename; a button-looking anchor cannot compensate for an HTML error page.

    How to check it

    Check resource origin and server response headers as well as the download attribute.

    Expected result

    You understand the browser's actual behavior rather than assuming universal support.

    Watch out: A suggested filename and download behavior are not universal guarantees.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.