Why this deep dive exists
Session 3 taught you to place an image with <img>. This dive teaches the two bigger moves: drawing graphics directly in markup with SVG, and embedding whole external things - videos, maps, other pages - with <iframe>. Both are pure HTML skills, and both show up constantly in the wild: every chart export, every icon set, every YouTube embed on every blog.
<object> and <template> when you meet them in view-source, and you know exactly which of today's elements need JavaScript before they do anything - honesty included.
Inline SVG - drawings written as text core
SVG is an image format made of markup: instead of storing pixels, it stores instructions - "a circle here, this big, this color". Because the instructions are text, an SVG stays razor sharp at any zoom, weighs almost nothing, and can be written by hand, by a tool, or by an AI. Every diagram on this course site is exactly this.
LiveThe shape vocabulary: rect, circle, line, text5 min▶
An <svg> element is a canvas; inside it, each child element draws one thing. <rect> takes a position (x, y) and a size; <circle> takes a center (cx, cy) and a radius r; <line> connects two points; <text> writes real, selectable text. Shapes paint in source order - later elements sit on top.
<svg viewBox="0 0 320 130" width="320"> <rect x="10" y="15" width="80" height="80" rx="12" fill="#E34F26"/> <circle cx="160" cy="55" r="40" fill="#F8A47F"/> <line x1="230" y1="95" x2="305" y2="15" stroke="#2B1D14" stroke-width="4"/> <text x="12" y="122" font-size="14">all of this is text</text> </svg>
One paragraph on viewBox, because it confuses everyone once: viewBox="0 0 320 130" defines the drawing's own coordinate system - "my world is 320 wide and 130 tall". The width attribute then says how big to display that world. Scale the display up or down and every shape scales with it, perfectly, because the browser is re-running the instructions, not stretching pixels.
This rhymes with everything a data person already loves. SVG is diagrams-as-code: version-controllable, diff-able, generatable. Matplotlib, plotly, and D3 all export SVG; when Claude draws you an architecture diagram, it is writing exactly these elements. Read the vocabulary once and every generated chart becomes editable text instead of a locked picture.
LiveBuild a tiny logo, then meet path4 min▶
Stack a few shapes and you have an icon. This is genuinely how favicons, logos, and UI icons get made - a circle, a letter, done. And when shapes are not enough, <path> draws anything: its d attribute is a walk ("Move to 10,80. Curve to 150,80...") that pens out any outline you can imagine.
<svg viewBox="0 0 120 120" width="110">
<circle cx="60" cy="60" r="52" fill="#FDF0EA"
stroke="#E34F26" stroke-width="7"/>
<text x="60" y="80" font-size="56" text-anchor="middle"
fill="#A6300F" font-family="Georgia">P</text>
</svg>
<svg viewBox="0 0 320 100" width="320">
<path d="M10,80 Q85,10 160,80 T310,80"
fill="none" stroke="#F06529" stroke-width="5"/>
</svg>
Self-studyimg src=".svg" vs inline svg - the tradeoff2 min read▶
You can use an SVG two ways, and MDN's vector graphics lesson turns on this choice:
- As a file:
<img src="logo.svg" alt="...">. Simple, cacheable, reusable across pages. But it is a sealed box - your page's CSS cannot restyle its insides. - Inline: paste the
<svg>...</svg>straight into the body, like every playground above. Now every shape is a real element in your page - stylable with CSS, readable by screen readers viarole="img"andaria-label, zero extra file requests. The cost: it bulks up your HTML and repeats on every page that uses it.
Rule of thumb: decorative or reused art → file. One-off diagrams you may want to style or tweak → inline. This course inlines everything, which is why you can inspect it all.
iframe - a page inside your page core
An <iframe> punches a window in your page and shows another document through it - complete with its own skeleton, its own styles, its own rules. It is how YouTube videos, Google Maps, and payment forms land on millions of sites that never touch the underlying code.
LiveYour first guest page3 min▶
Two attributes matter from day one: src points at the document to show, and title describes it for screen-reader users - an iframe without a title is an unlabeled door, so treat title as required. Below, the guest page is written inline via srcdoc so it renders in our sandbox; in the wild you will almost always use src="https://...".
<p>This paragraph lives in YOUR page.</p>
<iframe title="A tiny guest page"
srcdoc="<h2>Hello from inside</h2>
<p>I am a separate document.</p>"
width="100%" height="120"
style="border: 3px solid #E34F26; border-radius: 10px">
</iframe>
<p>And this one lives in your page again.</p>
LiveThe embed pattern: YouTube, maps, and the safety belt4 min▶
The pattern every "share → embed" button hands you is the same five lines. Our sandboxed playgrounds cannot load external sites, so this one is copy-paste for your own file - drop it in your project page and reload:
title="Video: what it shows"
width="560" height="315"
loading="lazy" allowfullscreen></iframe>
Honest note: this only comes alive in a real page, not in the course playgrounds - external sites refuse to load inside our no-script sandbox.
sandboxis the safety belt. Adding a baresandboxattribute strips the guest of its powers: no scripts, no forms, no popups. You then hand back only what it needs, likesandbox="allow-scripts". Embedding content you do not fully trust without it is lending your page to a stranger.loading="lazy"tells the browser not to fetch the iframe until the reader scrolls near it - free speed for below-the-fold embeds, same attribute you will meet again on images in deep dive 6.3.- Some sites refuse to be framed. If an embed shows up blank, the site likely sends headers forbidding embedding (banks and login pages do this on purpose). Use their official embed URL, not the normal page URL.
Dashboards live this way too: Tableau Public, Looker Studio, and Streamlit apps all ship "embed" snippets that are plain iframes. A data person who knows the iframe pattern can put a live dashboard into any wiki, portal, or personal page in one paste - title and lazy loading included.
Self-studyembed and object - the honest history card2 min read▶
Before iframes won, pages bolted on external content with plugins: <embed> and <object> were the sockets that Flash movies, Java applets, and PDF viewers plugged into. The plugins are gone (Flash retired in 2020), but you still meet these elements in older codebases, so recognize them:
<object data="report.pdf" type="application/pdf">- the one still-legitimate use: showing a PDF inline, with fallback content between the tags for browsers that cannot.<embed>- same era, fewer features, no fallback mechanism. If you are writing new code, you basically never want it.
Why iframe wins today: it embeds real web documents rather than plugin content, it has the sandbox security model, lazy loading, and a title for accessibility. MDN's own lesson title tells the story - "from object to iframe" is the direction of travel.
template, slot, and shadow DOM - HTML that waits for JavaScript honesty-first
One family of elements exists purely as raw material for JavaScript. This course teaches HTML, not JS - so the goal here is honest recognition: know what these look like and what they are for, so nothing in view-source ever mystifies you.
Livetemplate - the invisible element (that is the lesson)3 min▶
Everything inside a <template> is parsed and held in memory but never rendered - no display, no image loading, no effect on the page. It is a stamp waiting for JavaScript to press it, once per row of data, once per card in a feed.
<p>Before the template.</p> <template> <p>Without JavaScript, you will never see me.</p> </template> <p>After the template. Notice the missing middle.</p>
Why it exists: before <template>, developers hid stamp-out markup in strings or hidden divs - which still loaded images and confused screen readers. The template element is the honest version: real HTML, officially inert.
Self-studyslot and shadow DOM - recognize the component model3 min read▶
Needs JavaScript - shown here so you recognize it in the wild, not to run it today. Custom elements (tags with a dash, like <user-card>) combine three ideas: a template for the stamp, a shadow DOM (a private, sealed subtree where the component's internals live, safe from the page's CSS), and <slot> - a labeled hole in the template where your content gets projected in.
<h3><slot name="title">Untitled</slot></h3>
<p><slot>No description.</slot></p>
</template>
<user-card>
<span slot="title">Phoebe Fu</span>
Data and AI person.
</user-card>
Inert until a script calls attachShadow and stamps the template. In our no-JS playgrounds this renders as plain text, so it lives in a box, not a playground.
Where you meet this daily: the <video> controls, browser date pickers, and design-system components (many Google and GitHub UI pieces) are all shadow DOM. When DevTools shows you #shadow-root, you now know what you are looking at.
Self-studyThe HTML APIs tour - where this course hands over2 min read▶
web.dev's "HTML APIs" chapter makes one big point worth carrying out of this course: every element you have learned also has a JavaScript surface. The document is queryable (querySelector finds elements the way CSS selectors do), every attribute is readable and writable from code, and rich elements expose whole method sets - <video> has play and pause, <dialog> has showModal, forms can validate themselves on demand.
Nothing to do today. Just know the door exists: the clean, semantic HTML you now write is precisely what makes the JavaScript course after this one pleasant - scripts navigate pages by the same structure and meaning you have been building since Session 1.
Try it yourself - this week ◐ 20-30 min total
- Ship one inline SVG to your live page: a decorative divider (the path wave above, recolored to your palette) or a monogram icon next to your h1. Give it
role="img"and anaria-label, push, and admire a drawing that weighs a few hundred bytes. - Build a second SVG from scratch in a playground: three shapes minimum, one text element, painted in your own colors. Copy your best one into a note - it is your icon starter kit.
- Embed one thing you love on your project page with the iframe pattern: a YouTube video or a public dashboard. Required:
title,loading="lazy". Bonus: try a baresandboxattribute on it and observe what breaks. - View source on a page with a YouTube embed and find the iframe. Then open DevTools on any page with a video player and hunt for
#shadow-root- wave at the component model.
Official sources covered
This dive teaches the working content of MDN's Including vector graphics in HTML and From object to iframe, plus the recognition layer of web.dev's Template, slot, and shadow chapter.
Three questions before you go 🎯 ◐ 90 seconds
1 · Your logo needs to stay sharp at any size AND change color with your page's CSS. Best move?
SVG stays sharp either way, but only inline SVG exposes its shapes as real elements your CSS can restyle. An img-loaded SVG is a sealed box.
2 · You embed a third-party widget you do not fully trust. Which attribute is the safety belt?
sandbox strips the guest page of scripts, forms, and popups until you explicitly hand powers back. lazy is speed, title is accessibility - both good, neither is security.
3 · A template element full of markup renders as... what?
Templates are parsed but never rendered - the invisible playground earlier was working correctly. That inertness is the feature JavaScript builds on.