logo
search
Others

How to Embed HTML or Code in Modern SharePoint Pages

Ayan MasoodAyan Masood Oct 10, 2026 871 views

Question details

The user needs to embed custom HTML, scripts, or iframes into a modern SharePoint page after discovering that older methods are no longer supported.

How to Embed HTML or Code in Modern SharePoint Pages
Product
Microsoft SharePoint
Device & OS
not provided
Scenario
Attempting to embed external HTML content, custom scripts, or a SharePoint URL into a modern SharePoint site page.
Observed behavior
Older workarounds, such as uploading an HTML file as an ASPX page, fail because modern SharePoint restricts unsupported page types and custom scripts for security reasons.
Before you start

Verify with your Microsoft 365 administrator that the external domain you want to embed is approved in your SharePoint site's HTML Field Security settings.

Solution 1Recommended

Use the SharePoint Embed Web Part

This is the primary and Microsoft-supported method to add HTML iframe snippets or embed URLs directly into a modern SharePoint page.

Modern SharePoint pages use an isolated, secure environment. The Embed web part allows you to display content from other sites (like YouTube, Bing maps, or internal SharePoint pages) as long as it uses standard iframe tags.

1
Edit the SharePoint page

Navigate to the modern SharePoint page where you want to embed the code and click 'Edit' in the top right corner.

2
Add the Embed web part

Hover your mouse over the page canvas until you see the circled '+' icon. Click it to open the web part menu, search for 'Embed', and select it.

3
Paste your embed code

In the property pane that opens on the right side of the screen, paste your HTML iframe code or secure website URL (starting with https://) into the 'Website address or embed code' box.

4
Save and publish

Review the preview generated on your page. If it looks correct, click 'Republish' or 'Save as draft' at the top of the page to apply your changes.

Use the SharePoint Embed Web Part
Script Tags Not Supported: The Embed web part explicitly strips out <script> tags for security purposes. You can only use iframe-based HTML codes here.
Free Microsoft Office alternative

Boost Your Team's Productivity with WPS Office

While SharePoint serves as your platform for site creation and intranet management, WPS Office is an excellent lightweight, high-performance alternative to Microsoft Office for creating, editing, and managing your actual documents. It offers premium features for a fraction of the cost, ensuring your team stays productive.

  1. 1. Download the software: Visit the official WPS Office website and download the installer tailored for your operating system.
  2. 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to install the suite on your device.
  3. 3. Edit your documents: Open WPS Office to immediately start creating, editing, and converting files with perfect compatibility.
Fully compatible with Microsoft Office document formats including .docx, .xlsx, and .pptx.Free, fast-loading, and completely lightweight, saving storage and system resources.Features a familiar, tabbed interface that requires zero learning curve for new users.Available across Windows, Mac, Linux, iOS, and Android for seamless cross-platform work.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my HTML file uploaded as ASPX no longer work in SharePoint?

Modern SharePoint environments strictly regulate custom script executions and block unsupported page types to prevent malicious code injections and cross-site scripting (XSS). As a result, legacy workarounds like renaming HTML to ASPX are permanently disabled on modern sites.

Can I use `<script>` tags in the SharePoint Embed web part?

No, the standard Embed web part in modern SharePoint automatically strips out `<script>` tags to comply with Microsoft's security protocols. To execute custom JavaScript, your organization must develop and deploy a custom SharePoint Framework (SPFx) web part.

Why am I getting an 'embedding is not supported' error when using an iframe?

This error typically appears when the external website's domain is not approved in your SharePoint site's security settings. A site administrator must navigate to 'HTML Field Security' in the site settings and explicitly add the domain to the allowed list.