All courses Custom code in Webflow

At the layout level (Code Embed element)

Go to the next lesson

At the layout level (Code Embed element)

Using the Code Embed element in your page layout.

At the layout level (Code Embed element)

Using the Code Embed element in your page layout.

How the Code Embed element works

The Code Embed element is used when custom code needs to live directly inside your page layout. It’s placed on the canvas, just like other elements, so it appears exactly where you add it.

A Code Embed element placed inside a layout and visible in the Navigator panel.

Inside the element, you can paste custom code such as HTML snippets, iframe embeds, or small CSS or JavaScript snippets. Once added, the embed becomes part of your layout and renders based on its position in the element hierarchy.

The Code Embed element requires a paid site plan or Workspace. If you don’t see it available, check your plan settings or review Webflow Plans & pricing.

How to use the Code Embed element

To add custom code to your layout using the Code Embed element:

  1. Decide where the embed should live by choosing or creating a container and setting up spacing, alignment, and responsiveness with Webflow’s native layout tools.
  2. Add a Code Embed element to the page and place it inside the appropriate section, div, grid, or component.
  3. Paste the embed code provided by the third-party tool, such as HTML, an iframe, or a script.
  4. Preview the page in Preview mode or by publishing to staging to confirm the embed loads and behaves as expected.
  5. Refine layout and styling if needed by adjusting parent elements or layout styles rather than editing the code itself.

Choosing the right embed code from third parties

Many third-party tools offer more than one way to embed their content. You might see options like:

  • iframe embeds
  • Script-based embeds
  • Inline vs global embed options

Third-party embed options showing different embed types, including an inline option.

When using the Code Embed element, look for embed options designed for inline or embedded use. These are meant to live inside page layouts and usually behave more predictably in Webflow.

The Code Embed element supports standard HTML, CSS, and JavaScript. Embeds meant for other frameworks won’t render in Webflow, so this is a good first thing to check if nothing appears.

Taking a moment to choose the right embed option upfront can save time troubleshooting later.

How Code Embed works with layout and styling

Code Embeds live inside your layout, so they can reference your project’s existing styles and variables. For example, you might reference a CSS variable instead of hardcoding a color value. This is useful when you want embedded content to stay aligned with your design system. 

And because the Code Embed element lives inside your page structure, it follows the same layout rules as other elements in your layout:

  • It can be nested inside Divs, grids, or components
  • Its parent elements control spacing, alignment, and responsiveness
  • It responds to breakpoints just like any other element

This also means that issues with embeds are often layout issues, not code issues. If an embed looks cramped, overflows, or behaves unexpectedly on smaller screens, the fix usually involves adjusting the surrounding layout or container styles.

Ready for more?

Now that you’ve got the Code Embed down, let’s look at how to use custom code at the page- and site-levels.

1

Getting started

Getting started

Getting started

Coming soon

1

Background & preview 2:00

Background & preview

Coming soon

1

Where you can add custom code 4:00

Where you can add custom code

Coming soon

2

Adding custom code

Adding custom code

Adding custom code

Coming soon

2

The Code Embed element 6:01

The Code Embed element

Coming soon

2

At the layout level (Code Embed element) 3:00

At the layout level (Code Embed element)

Coming soon

2

Page & site level code 3:36

Page & site level code

Coming soon

2

Page-level code 3:00

Page-level code

Coming soon

2

Site-level code 4:00

Site-level code

Coming soon

2

Adding custom code

Custom code in the Webflow CMS 3:01

Custom code in the Webflow CMS

Coming soon

2

In the Webflow CMS 5:00

In the Webflow CMS

Coming soon

3

Managing custom code

Managing custom code

Managing custom code

Coming soon

3

Previewing, testing, & troubleshooting 5:00

Previewing, testing, & troubleshooting

Coming soon

3

Best practices for maintainable code 4:00

Best practices for maintainable code

Coming soon

4

Wrap up

Wrap up

Wrap up

Coming soon

4

Try it: use the Code Embed element 4:00

Try it: use the Code Embed element

Coming soon

4

Wrap up

Try it: add page-level code 4:00

Try it: add page-level code

Coming soon

4

Wrap up

Try it: add site-level code 4:00

Try it: add site-level code

Coming soon

4

Additional resources 2:00

Additional resources

Coming soon

Course progress

0%

Assessment

Test your knowledge

Up next

Page & site level code

Add custom code that runs behind the scenes across a page or an entire site.

Continue to next lesson → Complete course ✓