“Upload an HTML file” can mean two different things in WordPress. If you want HTML markup to render inside a post or page, use the block editor’s Custom HTML block. If you need to store an existing .html document so visitors can download it, upload it through Media → Add New and link it with a File block.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
These workflows produce different results. A Custom HTML block becomes part of the WordPress page. A Media Library upload remains an attachment and is presented as a file link; it does not convert the document into a standalone WordPress page. The steps, permissions and troubleshooting paths below cover both cases.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose the result you actually need
Decide what a visitor should see after clicking or opening the content before you upload anything.
| What you want | Use this workflow | What visitors receive | Important conditions |
|---|---|---|---|
| HTML elements displayed as part of a post or page | Block editor → Custom HTML | The markup is rendered in the page layout | Scripts, iframes and some other tags may be removed unless your account has the unfiltered_html capability |
An existing .html document available as a file |
Media → Add New, then a File block | A download or file link to the uploaded document | Your site must accept the file type, and the hosting account must allow the file size and write access to wp-content |
| A document already hosted on another server | Use an external link or a supported embed | The visitor follows the external URL or views the embed | The remote server must permit access and continue serving the file |
Uploading a document to the Media Library is therefore not a method for replacing your theme, creating a new template or turning the file into a full WordPress page. Use the editor when the code must appear in page content.
#1 Best Overall
Method 1: Render HTML inside a WordPress post or page
This is the appropriate method for a fragment of markup such as a callout, a custom table, a form wrapper or a small section of a landing page.
Open the page editor
- Sign in to the WordPress dashboard.
- Open Pages or Posts, then select the item you want to edit. Choose Add New if you are creating a new item.
- Place the cursor where the HTML should appear. The block editor works one block at a time, so choose the exact position rather than pasting code into the title or paragraph text.
Insert a Custom HTML block
- Select the Block Inserter (+).
- Search for Custom HTML and select it. You can also type
/htmlin a new paragraph and press Enter. - Enter or paste the markup into the block’s HTML editor.
- Use the block’s preview to check how WordPress interprets the output.
- Select Update (or Publish for a new item) to save the page.
A small, self-contained fragment is easier to maintain than an entire exported website. Keep the page’s normal WordPress blocks for headings, navigation, images and reusable content when they already provide the required result, and reserve Custom HTML for markup that genuinely needs it.
Example of a content fragment
<section>
<h2>Getting started</h2>
<p>Follow these three steps to begin.</p>
</section>
The example is a content fragment, not a complete document. Do not expect a pasted <html>, <head> and <body> structure to replace the WordPress theme. The block is inserted inside the page that WordPress has already generated.
WordPress 7.0: HTML, CSS and JavaScript panels
Starting in WordPress 7.0, the Custom HTML block has separate panels for HTML, CSS and JavaScript. The CSS and JavaScript panels are available only to users with the unfiltered_html capability. This capability is an authorization setting, not a browser setting.
Rank #2
When an account lacks that capability, WordPress sanitizes the block with wp_kses() when the post is saved or updated. Disallowed markup can include <script> and <iframe>, so code that appears in the editor may not remain after you save. A preview that works before saving is not proof that the saved page will retain every tag.
Check the saved result
- Save the post or page.
- Open the public URL in a new browser tab, preferably while logged out or in a private window.
- Compare the rendered result with the editor preview.
- If an element disappeared, inspect whether it depends on a restricted tag or on the
unfiltered_htmlcapability rather than immediately pasting it again.
For code that requires JavaScript or an iframe, involve a site administrator who can verify the capability and the security implications. Do not ask for unrestricted markup access merely to solve a formatting problem that ordinary blocks can handle.
Method 2: Upload an .html document as a downloadable file
Use this route when you want visitors to obtain the original file—for example, a static reference document, an exported report or an offline copy. The result is an attachment URL and a link, not a page rendered inside your theme.
Upload through the Media Library
- In the dashboard, open Media → Add New. You can also open the Media Library and use its upload control.
- Drag the
.htmlfile into the upload area, or select Select Files and choose it from your computer. - Wait for WordPress to finish processing the upload. If the multi-file uploader fails in your browser, use the Browser Uploader fallback shown by WordPress.
- Open the new attachment’s details in the Media Library.
- Copy the read-only File URL. This is the address you can place in a link or a block.
The upload may fail before the file is stored. The most common reason is that the installation does not permit the HTML MIME type. Resolve that policy issue deliberately with an administrator; do not repeatedly rename the extension or enable broad file types without understanding what the server will serve.
Add the download link to a page
- Edit the target post or page.
- Insert a File block.
- Choose Upload to select a new file, or choose Media Library and select the file you already uploaded.
- If you copied the File URL, paste it into a normal link instead.
- Save or publish the page, then test the link as a visitor.
The File block is designed to provide a downloadable link. Depending on the visitor’s browser and server headers, selecting an HTML document might display its source or render it as a document, but that behavior does not make the document a WordPress page and is not controlled by the block.
When an external file is enough
If the document already lives on a server you control, a normal external link can avoid a second copy in the Media Library. Confirm that the remote URL is stable, publicly reachable by the intended audience and allowed to be linked or embedded. If the remote owner removes the file or changes permissions, your WordPress link will stop working.
Why WordPress says “This file type is not allowed”
WordPress can reject .html uploads for security reasons. A WordPress support response notes that the core installation may block the extension even when a plugin setting appears to permit it. The message is therefore not necessarily evidence that the file is corrupt.
Use an administrator-controlled file-type decision
- Confirm that the requested extension is genuinely needed. If the goal is rendered page content, return to the Custom HTML workflow instead of enabling document uploads.
- Ask an administrator to review the site’s permitted MIME types and the consequences of allowing HTML documents.
- Where the site’s policy allows it, use a controlled MIME-type code change or a reputable file-type plugin, with the change documented and limited to the required extension.
- Test the uploaded file from a non-administrator account and in a private browser window.
Allowing HTML files increases the number of places where active markup can be stored and served. Treat the change as a security decision, not as a harmless media preference. A plugin setting that appears to allow the extension does not override every server or WordPress rule.
Rank #4
Fix upload-size errors
The Media → Add New screen displays the maximum upload size configured by the hosting provider. If WordPress reports that the file is too large, the limit comes from the host or server configuration rather than from the File block.
Check the actual limit
- Open Media → Add New and read the maximum upload-size message shown below the upload area.
- Compare that value with the size of the HTML file on your computer.
- If the document exceeds the displayed limit, ask the hosting provider or server administrator whether the limit can be changed for the site.
- If the limit cannot be changed, reduce the document’s size only when doing so will not remove required content, or host the file externally and link to it.
Do not confuse a large page assembled from many images, scripts or stylesheets with a large .html text file. The upload limit applies to the file being sent, while referenced resources may be fetched separately by a browser.
Recommended Free Tools
Fix permission-denied and upload-directory errors
WordPress documentation warns that media uploads may require correct permissions for the wp-content directory. A permission error means WordPress cannot write to the location configured for uploads; it is not solved by editing the page content.
What to check
- Record the complete error shown by WordPress, including any named directory.
- Ask the hosting or server administrator to verify ownership and write permissions for
wp-contentand its uploads location. - Check whether a security policy, read-only deployment or recent migration changed the filesystem configuration.
- Retry a small, ordinary media file after the configuration is corrected. This distinguishes a general upload problem from an HTML-specific file-type block.
Avoid changing filesystem permissions broadly or recursively without an administrator’s plan. Overly permissive directories can create a larger security problem than the original upload failure.
Best Value
When scripts, iframes or styles disappear
Unexpectedly missing markup after saving usually indicates sanitization or a capability difference between users. WordPress applies wp_kses() to content saved by users who do not have unfiltered_html, and disallowed tags such as <script> and <iframe> can be removed.
Diagnose the cause
- Save the block and reopen it. If the tag has vanished from the saved HTML, sanitization occurred before the browser displayed the page.
- Ask an administrator to confirm whether the editing account has
unfiltered_html. - Check whether the site’s role or multisite policy intentionally withholds that capability.
- Replace unnecessary scripts or iframes with native WordPress blocks or a vetted integration when possible.
Do not paste the same script repeatedly: once WordPress has removed it on save, repeating the operation will not change the policy. If unrestricted markup is approved, have the administrator review the script’s origin, permissions and maintenance owner before enabling it.
Free tools Windows power users keep installed
One-click scans. No signup required.
Security and maintenance considerations
HTML is not always passive text. Scripts, iframes, event attributes and externally loaded resources can change what a visitor’s browser executes. The two upload workflows expose different surfaces:
- Custom HTML: code runs in the context of the page if WordPress permits it and the browser accepts it. Limit editing access and review every script or iframe.
- Media Library HTML: the file is stored and linked as an attachment. Its treatment when opened depends on the server response and the visitor’s browser, so test the actual public URL.
- External link: your site stores only the link, while availability and behavior remain under the remote server’s control.
Keep the original file in version control or another controlled archive before uploading revisions. Give similarly named files a clear version or date, then replace links intentionally rather than leaving several ambiguous copies in the Media Library.
A practical decision checklist
- Need code to appear inside an existing page? Choose Custom HTML.
- Need visitors to download the original document? Choose Media → Add New and a File block.
- Need JavaScript or an iframe? Confirm
unfiltered_htmland obtain administrator approval. - Rejected extension? Review the site’s MIME-type policy instead of renaming the file blindly.
- File too large? Compare it with the maximum size shown on Media → Add New and contact the host if necessary.
- Permission error? Have the server administrator check write access to
wp-content. - Only need a link to an existing document? Use its external URL after verifying access and stability.
Test both the editor result and the public link
Finish by testing the outcome that your reader will experience, not just the dashboard operation.
- For a Custom HTML block, view the published page while logged out and verify headings, links, styles and any permitted interactive behavior.
- For an uploaded document, open the File block link in a private window and confirm that it points to the intended File URL.
- Check the result on a second browser. HTML attachments may be displayed differently depending on browser handling and server headers.
- Reopen the editor after saving to ensure required markup was not sanitized.
- If the file is linked from several pages, update those links when replacing or deleting the attachment.
Once you identify whether the requirement is rendered content or a downloadable document, WordPress’s interface provides a clear path. The key is keeping those two outcomes separate: Custom HTML edits page content, while the Media Library stores a file that must be linked.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




