Embedding and web termsUpdated
Embed code
Also called: embed snippet, embed HTML, widget code
Definition
Embed code is a snippet of HTML you paste into a web page to display content hosted somewhere else, such as a video, a social media post or a widget. It's usually an iframe tag, a script tag with a placeholder element, or a combination.
The common forms
| Form | Example | Trade-off |
|---|---|---|
| A single <iframe> | LinkedIn's “Embed this post” code | Works without JavaScript, but the height is fixed |
| A placeholder plus a <script> | A widget loader that finds the placeholder and fills it | Can size itself; needs a builder that allows scripts |
| Generated from a URL | A CMS that turns a pasted link into an embed via oEmbed | No code to copy, but only for providers the CMS supports |
| A plain link or image | A screenshot linked to the original | Works everywhere, including email, but never updates |
Where it goes
Paste embed code into a block made for raw HTML, often called an HTML, code or embed block. A normal text block treats the code as words and shows it on the page. Several builders also skip custom code in their editor and run it only on the published page, so check the live URL before deciding it's broken. Step-by-step help for each builder is in the integration guides.
What to check before pasting
- Where it loads from: the domain in the code is the company you're trusting with part of your page.
- What it stores: whether it sets cookies affects your privacy policy and consent banner.
- Your security settings: a Content Security Policy may need that domain added.
- Accessibility: an iframe should carry a title that describes its content.
- IDs in the code: leave them as they are; they're how the code finds the right content.
- Size: a fixed height that looks right on desktop may cut content off on a phone.
Choosing between LinkedInEmbed's two snippets? See script or iframe embed code.
Sources
Related terms
- iframe
- An iframe (inline frame) is an HTML element, <iframe>, that displays a separate web page inside the current one. The embedded page loads from its own address and runs as its own document, kept apart from the host page's styles and scripts.
- Script tag (async and defer)
- A script tag, <script>, adds JavaScript to a web page. By default an external script pauses HTML parsing while it downloads and runs; the async and defer attributes let the browser keep parsing and run the script later.
- oEmbed
- oEmbed is an open format that lets a website turn a pasted link into embedded content. The site asks the content provider's oEmbed endpoint about the URL and gets back data such as a title, a thumbnail and, for rich content, ready-made HTML.
- Content Security Policy (CSP)
- A Content Security Policy (CSP) is a set of rules a website sends to the browser, usually in a Content-Security-Policy header, saying which sources the page may load scripts, frames, images and other resources from. Anything not allowed is blocked.
- Auto-resizing iframe
- An auto-resizing iframe changes its height to match the content inside it, so there's no inner scrollbar or empty gap. Because a page can't measure a cross-origin frame's content, the frame reports its height with postMessage and a script on the host page applies it.
Show your LinkedIn on your website
Paste a LinkedIn URL and embed it with one snippet. Free plan, no credit card.
Put your LinkedIn on your website today
Create your first widget in about two minutes. Free plan, no credit card required.