Skip to main content

embed (HTML element)

By Adam Roberts

HTML & CSS

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

Description

embed is a non-standard but well-supported element that’s used to embed multimedia content, including media types that mightn’t usually be natively supported by the browser. It can also be used for embedding media types that are supported, such as images in .jpg, .gif, or .png format.

embed isn’t part of any currently recognized standard, so if you use it, your page can’t possibly validate; to create valid markup, you’ll need to use the object element, which was defined in HTML 4. That said, using embed is widely recognised as a good way to embed Flash in an accessible manner, and many believe that it’s acceptable to compromise validity for the sake of accessibility.

embed won’t work for formats that are natively supported in the browser, such as HTML and images — use the built-in, properly supported mechanisms for such formats. The formats that embed supports are generally restricted to those that would require an additional plugin in order to work.

Although embed is an empty element, an end tag is still required for the sake of browser compatibility.

Example

In this example, a super-simple embed element is used to display a video file in .mp4 format:

<embed src="volksworld-video-report.mp4">
</embed>

Use This for…

This element is used for media files (primarily movie files, such as Flash and QuickTime video).

In this Section

Adam is SitePoint's head of newsletters, who mainly writes Versioning, a daily newsletter covering everything new and interesting in the world of web development. He has a beard and will talk to you about beer and Star Wars, if you let him.

New books out now!

Learn how Git works, and how to use it to streamline your workflow!


Google, Netflix and ILM are Python users. Maybe you should too?