HTML Code Embedding Squarespace

You want to add a booking widget, a custom payment form, or an interactive map to your Squarespace site, but the visual editor has no option for any of them. Squarespace's Business plan, required for Code Block access, powers over 3 million active websites globally, making HTML embedding one of the most-searched customization topics for the platform.

Embedding HTML in Squarespace opens up every piece of functionality the visual editor cannot deliver on its own. Google Forms, Calendly widgets, Stripe payment buttons, HubSpot lead capture forms, custom countdown timers, if it exists as HTML, you can get it onto a Squarespace page. This guide covers every method for embedding HTML in Squarespace: Code Blocks, Code Injection, and Markdown Blocks, with step-by-step instructions, a quick method comparison, plan-level details, and troubleshooting for the issues most guides skip.

HTML Code Embedding Squarespace

The right embedding method depends on where the code needs to run and what plan you are on. Code Blocks place your embed at a specific location on a specific page. Code Injection runs code on every page of the site. Markdown Blocks handle static HTML without JavaScript. Each serves a distinct purpose, and using the wrong one is the most common source of embedding problems. Squarespace supports Code Blocks and Code Injection on Business plans and above. Use coupon code OKDIGITAL10 for 10% off any Squarespace plan.

Quick Reference: Which Method to Use

Before touching the editor, match your use case to the right method. Using the wrong insertion point is the fastest way to create embedding problems that are hard to diagnose.

Use Case Method Why
Form, widget, map, payment button on one page Code Block Renders inline at a specific spot
Analytics tracking, Google Tag Manager, global fonts Code Injection (Header) Runs on every page, loads early
Chat widget, cookie banner, exit-intent script Code Injection (Footer) Runs on every page, loads after content
Styled HTML table, static div, formatted text block Markdown Block Accepts HTML, no JavaScript needed
JavaScript widget that needs a DOM container Code Block + Code Injection Container on the page, script in footer

HTML Embedding by Squarespace Plan

Not every Squarespace plan grants the same access to custom code. Getting this wrong wastes time, so here is exactly what each plan supports.

Personal plan: No Code Blocks. No Code Injection. Markdown Blocks are available but only accept basic static HTML, with no script tags or iframes. This plan is not suitable for custom widget or form embedding.

Business plan: Full access to Code Blocks and Code Injection. This is the minimum plan required for any meaningful HTML embedding. JavaScript runs in Code Blocks and Code Injection. A Squarespace badge appears in the site footer on Business plans.

Commerce Basic and Commerce Advanced: Same code access as Business, with the Squarespace footer badge removed. These plans add e-commerce features but do not change what you can do with HTML embedding.

Enterprise: Same embedding tools, plus dedicated support that can assist with complex custom code implementations.

Method 1: Embedding HTML Using Code Blocks

Code Blocks are the most common way to embed HTML in Squarespace. They insert your code at a specific location on a specific page, rendering it inline with surrounding content. This is the right method for embedded forms, widgets, maps, payment buttons, and any HTML element that belongs at one spot on one page.

For a dedicated guide on video embedding specifically, see how to add a video to Squarespace.

How to Add a Code Block

Open the page editor and click a content insertion point (the plus icon between sections or blocks). Select Code from the block menu. If it does not appear in the initial list, click "More" to expand all block types. Paste your HTML into the Code Block editor, confirm the display mode is set to HTML (not Markdown), and click Apply.

The embedded HTML renders immediately in the page preview. Check the output on both desktop and mobile. Some embedded elements, particularly iframes and widgets with fixed dimensions, need width adjustments to display correctly on smaller screens. Our guide to adding custom CSS to Squarespace covers how to make embedded elements adapt to any screen size.

Specific Embeds and How to Handle Each

Google Forms: Open the form, click Send, select the embed tab (the angle-bracket icon), and copy the iframe code. Paste into a Code Block. Set width to "100%" and height to 600-800px depending on form length.

HubSpot forms: In HubSpot, go to Marketing > Forms, select your form, and click Share > Embed. Copy the JavaScript snippet (not the iframe version, as the JS version handles validation and styling correctly). Paste it into a Code Block. HubSpot's script renders the form dynamically, so the Code Block will appear blank in the editor. The form appears correctly on the published page.

Calendly widgets: On your Calendly event page, click Share > Add to Website, then select "Inline Embed" for a form embedded directly in the page. Copy the code snippet and paste into a Code Block. The inline embed requires a minimum height of around 630px to display without a scrollbar.

Stripe payment links: Stripe's "Buy Button" feature generates an embeddable button. In the Stripe Dashboard, go to Payment Links, select a link, and click "Buy Button." Customize the button style, then copy the two-part embed: a script tag and a stripe-buy-button element. Paste both into a single Code Block. The script tag must be present in the same Code Block for the button to initialize.

PayPal buttons: In PayPal, create a payment button via Tools > PayPal Buttons and copy the generated HTML. Paste into a Code Block. PayPal buttons use a form element with an action URL. Keep the entire form block intact or the button will not process payments.

Google Maps: On Google Maps, find your location, click Share, select "Embed a map," and copy the iframe code. Paste into a Code Block and set width to "100%".

Custom HTML tables: Squarespace does not include a native table block. Build your table markup (or use an HTML table generator), paste it into a Code Block, and add inline styles or link to Design > Custom CSS for consistent table styling across the site. For broader design approaches, our Squarespace design tips guide covers visual consistency strategies.

Method 2: Embedding HTML Using Code Injection

Code Injection inserts HTML, CSS, or JavaScript into the site header or footer, running on every page rather than at one specific location. This is the right method for analytics scripts, tracking pixels, custom font imports, cookie consent banners, live chat widgets, and any code that needs to load globally.

Access Code Injection at Settings > Advanced > Code Injection. The Header field inserts code inside the <head> tag. The Footer field inserts code just before the closing </body> tag. For a full walkthrough of every injection point, see our guide to custom code injection on Squarespace.

Header vs. Footer: Which Field to Use

Put analytics scripts, meta tags, and font imports in the Header. These need to load before the page content renders. Put chat widgets, exit-intent scripts, and anything that interacts with the DOM in the Footer. These need the page to load first. Putting a DOM-dependent script in the Header is a common cause of widgets that silently fail to initialize.

When to Use Code Injection Instead of Code Blocks

Use Code Injection when the code needs to run on every page: analytics tracking, site-wide widgets, custom fonts, and meta tags. Use Code Blocks when the code should only appear at a specific location on a specific page. Mixing these up is the most common HTML embedding mistake. A site-wide script in a Code Block means it only runs on one page, and a page-specific widget in Code Injection means it appears everywhere.

Method 3: Embedding HTML in Markdown Blocks

Markdown Blocks in Squarespace also accept raw HTML. This method is less common than Code Blocks but useful when you are mixing Markdown-formatted text with HTML elements on the same block. Add a Markdown Block, switch to raw HTML mode, and paste your code.

The main limitation of Markdown Blocks is that they do not support JavaScript. Script tags are stripped. If your embed code includes script tags, use a Code Block instead. Markdown Blocks are best for static HTML: formatted text, tables, styled divs, and image galleries that do not require JavaScript functionality.

Best Practices for HTML Embedding in Squarespace

Set widths to 100%. Fixed-pixel widths on iframes and divs break on mobile. Use width="100%" or CSS max-width instead of hardcoded values.

Test on a real device, not just the preview. The Squarespace mobile preview gives a general sense of layout but does not replicate all browser behaviors. Load the published page on an actual phone to confirm the embed renders correctly.

Label your Code Blocks. Add an HTML comment at the top of each Code Block describing its contents, for example <!-- HubSpot contact form -->. This makes future edits faster when a page has multiple embeds.

Validate before embedding. Malformed HTML (unclosed tags, missing quote characters, broken attributes) can affect layout elements outside the Code Block. Paste your code into an HTML validator before adding it to the page.

Only embed code from sources you trust. Malicious scripts can capture visitor data or inject unwanted content. Verify every embed snippet before publishing. For safe code practices, our guide to adding custom code to Squarespace covers this in detail.

Troubleshooting HTML Embedding Issues

Embedded Code Not Rendering

Check that the Code Block is set to HTML mode, not Markdown. Verify the code is complete, as missing closing tags or broken script references prevent rendering. Open the browser console (F12 > Console tab) and check for JavaScript errors if the embed relies on a script.

Embed Breaks Page Layout

An iframe or div with a fixed width wider than the page container pushes content off screen. Set width to 100% or wrap the element in a div with overflow: hidden. Also check whether the embed includes a hardcoded min-width in its own styles, which can override your CSS.

Embed Works on Desktop but Not Mobile

Fixed pixel dimensions are almost always the cause. Replace fixed widths with percentage values. For iframes that need a locked aspect ratio, wrap them in a container div with padding-bottom: 56.25% (for 16:9) and set the iframe to position: absolute; width: 100%; height: 100%. Our guide to customizing your Squarespace website covers responsive design fundamentals in detail.

Third-Party Widget Blocked by HTTPS

Squarespace sites run on HTTPS. If you embed a widget from an HTTP-only source, browsers block it as mixed content and display nothing. Check whether the third-party service offers an HTTPS embed URL. If they only provide HTTP, contact their support team or switch to a service that supports HTTPS.

Iframe Shows a Blank Box

Some services set X-Frame-Options: DENY or Content-Security-Policy: frame-ancestors 'none' on their servers, which blocks their pages from loading inside any iframe. This is a server-side restriction with no workaround from Squarespace's side. Use the service's JavaScript embed method instead of the iframe URL.

HubSpot or JavaScript Widget Appears Blank in the Editor

JavaScript-rendered widgets (HubSpot forms, certain chat tools, dynamic countdown timers) render on the published page, not in the Squarespace editor preview. The Code Block will appear blank while editing. Click "Done" and view the published page to confirm the widget loads. Do not assume the embed is broken just because the editor shows nothing.

Stripe Buy Button Not Initializing

Stripe's Buy Button requires both the <script> tag and the <stripe-buy-button> element to be present in the same Code Block. If you paste them into separate Code Blocks, the button element renders but the script does not find it and the button stays blank. Always keep both parts of the Stripe snippet in a single Code Block.

Calendly Widget Cutting Off

Calendly's inline embed defaults to a minimum height of around 630px. If the Code Block container is shorter, the widget gets cut off or shows a scrollbar inside the embed frame. Set the height attribute on the Calendly container div to at least 630px, or taller if your event type has additional fields.

Frequently Asked Questions

How do I embed HTML code in Squarespace?

Add a Code Block to your page by clicking the plus icon in the page editor, selecting Code from the block menu (under "More" if it is not visible), pasting your HTML, setting the display mode to HTML, and clicking Apply. The embedded code renders inline at that spot on the page. For site-wide code that needs to run on every page, use Code Injection under Settings > Advanced instead.

Do I need a specific Squarespace plan to embed HTML?

Code Blocks and Code Injection require a Business plan or higher. Personal plan users cannot use Code Blocks or Code Injection. All plans support Markdown Blocks, which accept basic static HTML but strip out any JavaScript. If you need to embed a form, widget, or script, the Business plan is the minimum requirement.

Can I embed JavaScript in Squarespace?

Yes. Code Blocks and Code Injection both support JavaScript. Use a Code Block for JavaScript that should run on one specific page, and Code Injection (Footer field) for scripts that need to run site-wide. Markdown Blocks do not support JavaScript, and script tags are stripped silently, so switch to a Code Block if your embed includes any script tags.

What is the difference between Code Blocks and Code Injection in Squarespace?

Code Blocks insert HTML at a specific location on a specific page. Use them for forms, widgets, payment buttons, and any visual element that belongs in one spot. Code Injection inserts code into the site header or footer on every page. Use it for analytics scripts, tracking pixels, chat widgets, and site-wide tools. Mixing these up is the most common embedding mistake on Squarespace.

Why is my embedded HTML not showing in Squarespace?

Start by confirming the Code Block is set to HTML mode (not Markdown). Check that the embed code is complete, with no missing closing tags. Some JavaScript-rendered widgets (like HubSpot forms) appear blank in the editor but load correctly on the published page. Always check the live page before assuming something is broken. Also confirm your plan supports Code Blocks (Business or higher).

How do I make embedded HTML responsive on Squarespace?

Set iframe and div widths to 100% instead of fixed pixel values. For iframes that require a specific aspect ratio, wrap them in a container div with position: relative; padding-bottom: 56.25% (for 16:9 video), then set the iframe to position: absolute; top: 0; left: 0; width: 100%; height: 100%. This gives you a fully responsive embed that scales correctly on any screen size.

Embed Anything on Your Squarespace Site

HTML embedding is what turns a Squarespace template into a site that does exactly what your business needs. Forms, booking widgets, payment buttons, maps, chat tools, custom timers: if it exists as HTML or a JavaScript snippet, it can live on a Squarespace page.

Use Code Blocks for page-specific embeds, Code Injection for site-wide scripts, and Markdown Blocks for static HTML without JavaScript. Match your plan level to what you need, keep widths responsive, and always check the published page rather than the editor preview for JavaScript-rendered elements.

Keep Reading

* Read the rest of the post and open up an offer
Top