Content elements: links, lists, images, semantics
Nesting and the family vocabulary
Slide 14 introduces terms you will use constantly in chapter 5, and names the concept outright: this hierarchy is the Document Object Model.
<body> ← ancestor of everything below <article> ← child of body, parent of h1 and p <h1>Title</h1> ← child of article, descendant of body <p>Text with <strong>emphasis</strong></p> </article> </body> RULE: a child's closing tag must come BEFORE its parent's. ✓ <p><strong>hi</strong></p> correct ✗ <p><strong>hi</p></strong> overlapping — invalid
Links — all eight kinds on one slide
<!-- destination = href, label = the text between the tags --> <a href="https://google.com">external site</a> <a href="about.html">another page on this site</a> <a href="#links">a place on THIS page</a> <a href="https://google.com/#links">a place on ANOTHER page</a> <a href="mailto:[email protected]">open the email program</a> <a href="javascript:runProgram()">run a JavaScript function</a> <a href="tel:0521212121">make a phone call</a> <a href="http://m.me/PAGE_USERNAME">open another program</a> <!-- the target of a #fragment is any element with a matching id --> <h2 id="links">Links section</h2> <!-- an image can be the label — this is the "clickable image" home task --> <a href="gallery.html"><img src="trulli.jpg" alt="Trulli houses"></a>
Relative URLs — all six forms
Absolute means the full URL: protocol, domain, path, filename. It is required when the resource is on another site. Relative means the browser asks the current server, and comes in exactly six shapes:
| Form | Written as | Meaning |
|---|---|---|
| 1. Same directory | page.html |
Just the file name. |
| 2. Child directory | images/photo.jpg |
Subdirectory name, slash, file name. |
| 3. Grandchild / descendant | assets/img/icons/x.svg |
Each subdirectory name in turn, separated by slashes. |
| 4. Parent / ancestor |
../styles.css ·
../../a.html
|
../ goes up one level; string several together
to go higher.
|
| 5. Sibling | ../css/styles.css |
Up with ../, then down like a child directory.
|
| 6. Root reference | /images/logo.png |
Leading / starts from the server root, then
down as normal.
|
/css/styles.css) keeps working no matter how
deep the page is, which is why it is safer for a shared stylesheet.
A same-directory reference breaks the moment you move the file into
a subfolder.
Lists — three kinds
<!-- 1. ORDERED: items with a set order. type = I, A, a, i --> <ol type="I"> <li>First</li> <li>Second</li> </ol> <!-- 2. UNORDERED: no particular order --> <ul style="list-style-type:square"> <!-- disc | circle | square --> <li>Chrome</li> <li>Firefox</li> </ul> <!-- 3. DESCRIPTION: name + description pairs. dt = term, dd = definition --> <dl> <dt>HTTP</dt> <dd>The protocol used for web communication.</dd> <dt>DNS</dt> <dd>Resolves domain names to IP addresses.</dd> </dl>
Images and character entities
<!-- img is an EMPTY element: no closing tag, no text content. src and alt are the key attributes; title/width/height are optional. --> <img src="trulli.jpg" alt="Trulli houses in Puglia" width="500" height="333"> <!-- Entities: characters you cannot type, or that HTML has reserved. Use the NAME or the NUMBER — both work. -->   non-breaking space < < < ← reserved: HTML would read it as a tag > > > © © © € € € ™ ™ ™ <p>To write a tag in text: <code><div></code> renders as <div></p>
Inline elements — do not break the flow of text
| Element | Use |
|---|---|
<a> |
Anchor, used for hyperlinks. |
<abbr> |
An abbreviation. |
<br> |
Line break. |
<cite> |
A citation — a reference to another work. |
<code> |
Displaying markup or programming code. |
<em> |
Emphasis. |
<small> |
Fine print — nonvital text such as copyright or legal notices. |
<span> |
The inline equivalent of <div>; marks
text for CSS.
|
<strong> |
Content that is strongly important. |
<time> |
Time and date data. |
HTML5 semantic structure
<body> <header> <!-- intro content for the page or a section --> <nav> <!-- a block of navigation links --> <a href="pagehtml.html">HTML</a> | <a href="pagecss.html">CSS</a> | <a href="pagejs.html">JavaScript</a> </nav> </header> <main> <!-- the dominant content. Only ONE per page. --> <h1>Survey</h1> <section> <!-- a thematic grouping, usually with a heading --> <h2>Most Popular Browsers</h2> <article> <!-- self-contained: makes sense on its own --> <h3>Google Chrome</h3> <p>Released by Google in 2008.</p> </article> </section> <figure> <!-- content that could MOVE and the document still makes sense --> <img src="chart.png" alt="Browser market share"> <figcaption>Fig 1. Market share, 2026.</figcaption> </figure> </main> <aside>Related links</aside> <!-- tangential content --> <footer>© 2026 Shoug</footer> </body>
<figure> test, stated exactly as the slide
does:
could this content be moved to a different place in the document and
the rest still make sense? If yes, it is a figure — and it
need not be an image.