Favicons and Iframes
HTML Living Standard
A favicon represents the page in the browser interface. An iframe puts a second document inside the page.
On this page
Add a favicon in <head>
A link with rel="icon" points to the icon. On a site its href often points to an image file such as ./favicon.svg. Here the icon is embedded in the HTML so the example works on its own. Open the saved HTML as a tab to see its icon beside the title.
How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Add a favicon in <head></title>
<link rel="icon" href="data:image/svg+xml,%3Csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20viewBox=%270%200%2032%2032%27%3E%3Ccircle%20cx=%2716%27%20cy=%2716%27%20r=%2714%27%20fill=%27teal%27/%3E%3C/svg%3E">
</head>
<body>
<h1><img id="icon" width="26" height="26" alt=""> Example Store</h1>
<script>
document.querySelector("#icon").src = document.querySelector('link[rel="icon"]').href;
</script>
</body>
</html>
What to expect The preview shows the same icon next to the heading. The site’s tab stays on the Docs page.
Embed a document with <iframe>
An iframe has its own document. Use src for a URL or srcdoc for inline HTML. A useful title tells assistive technology what is inside. Some websites refuse embedding. This example keeps its content inline and uses a sandbox with no additional permissions.
How to try it Save this example as a new .html file, then open it in your browser. After a change, save and reload.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Embed a document with <iframe></title>
<style>
iframe { width: min(100%, 300px); box-sizing: border-box; border: 1px solid teal; }
</style>
</head>
<body>
<h2>Opening hours</h2>
<iframe title="Weekly opening hours" sandbox
srcdoc="<p>Monday–Friday, 9–5</p>"></iframe>
</body>
</html>
What to expect Opening hours appears in the outer page and Monday–Friday, 9–5 appears inside the frame.
Build a media gallery
Put three photos in an images folder. Give each figure a visible caption and write alt text explaining what matters in the image. Temporarily break one image path to check the fallback. Add a caption track to a video and enable it during playback.