Week 3: Semantic HTML & Multimedia
HTML | Semantic Elements, Audio, Video, Accessibility
Web Development 1
WEEK 03
1. Why Semantic HTML Matters
Semantic HTML means using HTML elements for their intended meaning, not just their visual appearance. Instead of using generic <div> and <span> for everything, we use elements like <header>, <nav>, <main>, <article>, and <footer> that clearly describe the purpose of the content.
Semantic vs. Non-Semantic
Non-Semantic (Bad)
<div id="header">
<div id="nav">...</div>
</div>
<div id="main">
<div class="article">...</div>
<div class="sidebar">...</div>
</div>
<div id="footer">...</div>
Semantic (Good)
<header>
<nav>...</nav>
</header>
<main>
<article>...</article>
<aside>...</aside>
</main>
<footer>...</footer>
Three Major Benefits
1. SEO (Search Engine Optimization)
Search engines like Google understand semantic elements. A <nav> tells Google "this is the navigation," an <article> tells it "this is the main content." This helps your pages rank higher in search results.
2. Accessibility
Screen readers (used by visually impaired users) rely on semantic elements to navigate pages. A screen reader can announce "Navigation area" when it encounters <nav>, or let users jump between <article> elements. Without semantic HTML, screen readers just see "div, div, div..."
3. Maintainability
Semantic HTML makes your code easier to read and maintain. When you see <header>, you immediately know it is the page header. When you see <div class="hdr-wrp-outer">, you have to figure it out.
2. Semantic Structure Elements
HTML5 introduced several elements specifically designed to describe the structure of a web page.
| Element |
Purpose |
Usage |
<header> |
Introductory content or navigation |
Page header, article header |
<nav> |
Navigation links |
Main menu, sidebar navigation |
<main> |
Primary content of the page |
One per page (unique content) |
<section> |
Thematic grouping of content |
Chapters, tabbed panels |
<article> |
Self-contained, reusable content |
Blog post, news story, comment |
<aside> |
Related but secondary content |
Sidebar, related articles, ads |
<footer> |
Footer of section or page |
Copyright, contact, site links |
Complete Page Structure Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Blog</title>
</head>
<body>
<!-- PAGE HEADER -->
<header>
<h1>My Tech Blog</h1>
<p>Web development tips and tutorials</p>
<!-- NAVIGATION -->
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Articles</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<!-- MAIN CONTENT -->
<main>
<!-- ARTICLE 1 -->
<article>
<header>
<h2>Getting Started with HTML5</h2>
<p>By Ahmed | <time datetime="2026-03-20">March 20, 2026</time></p>
</header>
<section>
<h3>Introduction</h3>
<p>HTML5 is the latest version of HTML...</p>
</section>
<section>
<h3>New Features</h3>
<p>HTML5 introduced semantic elements, multimedia support...</p>
</section>
<footer>
<p>Tags: HTML, Web Development, Beginners</p>
</footer>
</article>
<!-- ARTICLE 2 -->
<article>
<header>
<h2>CSS Flexbox Guide</h2>
<p>By Sara | <time datetime="2026-03-18">March 18, 2026</time></p>
</header>
<p>Flexbox makes layout much easier...</p>
</article>
</main>
<!-- SIDEBAR -->
<aside>
<h3>Related Articles</h3>
<ul>
<li><a href="#">CSS Grid Layout</a></li>
<li><a href="#">JavaScript Basics</a></li>
</ul>
<h3>About the Author</h3>
<p>Web developer and teacher at Al-Aqsa University.</p>
</aside>
<!-- PAGE FOOTER -->
<footer>
<p>© 2026 My Tech Blog. All rights reserved.</p>
<address>
Contact us at <a href="mailto:info@myblog.com">info@myblog.com</a>
</address>
</footer>
</body>
</html>
When to Use Each Element
<header>
Used for introductory content. Can be used for the page header AND for headers inside articles and sections. A page can have multiple <header> elements.
<!-- Page header -->
<header>
<h1>Website Title</h1>
<nav>...</nav>
</header>
<!-- Article header -->
<article>
<header>
<h2>Article Title</h2>
<p>Published on March 26, 2026</p>
</header>
<p>Article content...</p>
</article>
<nav>
Used for major navigation blocks. Not every group of links is a <nav> — only the main navigation areas.
<!-- Main site navigation -->
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/courses">Courses</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
<!-- Breadcrumb navigation -->
<nav aria-label="Breadcrumb">
<a href="/">Home</a> >
<a href="/courses">Courses</a> >
<a href="/courses/web-dev">Web Development</a>
</nav>
<main>
Contains the primary content unique to this page. There must be only one <main> per page, and it should not be nested inside <header>, <footer>, <nav>, or <aside>.
<section> vs. <article>
When to use which?
<article>: Self-contained content that makes sense on its own (could be syndicated). Examples: blog post, news article, user comment, product card.
<section>: A thematic grouping of content that is part of something larger. Examples: a chapter of a document, a tab panel, "About Us" section.
- Rule of thumb: If the content would make sense in an RSS feed by itself, use
<article>. If it is a section of a larger document, use <section>.
<aside>
Content that is tangentially related to the main content. Think sidebars, pull quotes, related links, advertisements.
<aside>
<h3>Did You Know?</h3>
<p>The first website was created in 1991 by Tim Berners-Lee.</p>
</aside>
3. Semantic Content Elements
<figure> and <figcaption>
Groups an image (or diagram, code listing, etc.) with its caption.
<figure>
<img src="chart.png" alt="Website traffic growth chart" width="600">
<figcaption>Figure 1: Website traffic increased 200% after implementing SEO.</figcaption>
</figure>
<!-- Figure with a code example -->
<figure>
<pre><code>console.log("Hello, World!");</code></pre>
<figcaption>Example: JavaScript Hello World program.</figcaption>
</figure>
<details> and <summary>
Creates a collapsible/expandable widget. Clicking the summary toggles the content visibility - no JavaScript needed!
<!-- Collapsible FAQ -->
<details>
<summary>What is HTML?</summary>
<p>HTML stands for HyperText Markup Language. It is the standard language
for creating web pages.</p>
</details>
<details>
<summary>Do I need to learn CSS too?</summary>
<p>Yes! CSS is used to style and layout your HTML pages.
You will learn CSS in the next section of this course.</p>
</details>
<!-- Open by default -->
<details open>
<summary>This is open by default</summary>
<p>This content is visible when the page loads.</p>
</details>
<time>
Represents a date, time, or date-time. The datetime attribute provides the machine-readable format.
<!-- Date -->
<p>Published on <time datetime="2026-03-26">March 26, 2026</time></p>
<!-- Date and time -->
<p>Meeting at <time datetime="2026-03-26T09:00">9:00 AM on March 26</time></p>
<!-- Duration -->
<p>Cooking time: <time datetime="PT30M">30 minutes</time></p>
<address>
Contains contact information for the author or owner of a page/article.
<address>
Written by <a href="mailto:ahmed@alaqsa.edu.ps">Ahmed</a>.<br>
Al-Aqsa University<br>
Gaza, Palestine
</address>
4. Audio Element
The <audio> element lets you embed audio files directly in your web page.
Basic Audio Player
<!-- Simple audio with controls -->
<audio controls>
<source src="audio/song.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Audio Attributes
| Attribute |
Description |
controls |
Shows play/pause, volume, progress bar |
autoplay |
Starts playing automatically (usually blocked by browsers) |
loop |
Restarts when finished |
muted |
Starts muted |
preload |
"auto", "metadata", or "none" |
<!-- Audio with all attributes -->
<audio controls loop preload="auto">
<source src="audio/background.mp3" type="audio/mpeg">
<source src="audio/background.ogg" type="audio/ogg">
Your browser does not support audio.
</audio>
Multiple Sources for Browser Compatibility
Different browsers support different audio formats. Provide multiple sources so the browser picks the first one it supports.
<audio controls>
<source src="song.mp3" type="audio/mpeg"> <!-- Most browsers -->
<source src="song.ogg" type="audio/ogg"> <!-- Firefox fallback -->
<source src="song.wav" type="audio/wav"> <!-- Last resort -->
<p>Your browser doesn't support audio. <a href="song.mp3">Download</a> instead.</p>
</audio>
Supported Audio Formats
| Format |
MIME Type |
Browser Support |
| MP3 | audio/mpeg | All modern browsers |
| OGG | audio/ogg | Chrome, Firefox, Opera |
| WAV | audio/wav | All modern browsers |
| AAC | audio/aac | Chrome, Safari, Edge |
5. Video Element
The <video> element embeds video content in your page.
Basic Video Player
<!-- Simple video with controls -->
<video controls width="640" height="360">
<source src="video/tutorial.mp4" type="video/mp4">
Your browser does not support the video element.
</video>
Video Attributes
| Attribute |
Description |
controls |
Shows play/pause, volume, fullscreen, progress |
width / height |
Dimensions of the video player |
poster |
Image shown before video plays (thumbnail) |
autoplay |
Starts automatically (needs muted to work) |
loop |
Loops the video |
muted |
Starts muted |
preload |
"auto", "metadata", or "none" |
<!-- Video with poster image and multiple sources -->
<video controls width="640" height="360"
poster="images/thumbnail.jpg"
preload="metadata">
<source src="video/tutorial.mp4" type="video/mp4">
<source src="video/tutorial.webm" type="video/webm">
<source src="video/tutorial.ogg" type="video/ogg">
<p>Video not supported. <a href="video/tutorial.mp4">Download</a></p>
</video>
Video with Subtitles: <track>
<video controls width="640">
<source src="lecture.mp4" type="video/mp4">
<!-- English subtitles (default) -->
<track src="subs-en.vtt" kind="subtitles"
srclang="en" label="English" default>
<!-- Arabic subtitles -->
<track src="subs-ar.vtt" kind="subtitles"
srclang="ar" label="Arabic">
</video>
Autoplay Policy
Most browsers block autoplay of videos with sound. If you need autoplay, you must also add the muted attribute. This is a browser policy to protect users from unwanted noise.
<!-- This works (autoplay + muted) -->
<video autoplay muted loop>
<source src="background.mp4" type="video/mp4">
</video>
6. Embedding with <iframe>
The <iframe> element embeds another HTML page (or external content) inside your page. It is commonly used for YouTube videos, Google Maps, and other third-party content.
Embedding a YouTube Video
<!-- YouTube embed -->
<!-- Go to YouTube > Share > Embed > copy the code -->
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
How to Get a YouTube Embed URL
- Go to the YouTube video
- Click "Share" below the video
- Click "Embed"
- Copy the
<iframe> code
The embed URL format is: https://www.youtube.com/embed/VIDEO_ID
Embedding Google Maps
<!-- Google Maps embed -->
<!-- Go to Google Maps > Share > Embed a map -->
<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3399.8!2d34.44!3d31.5!..."
width="600"
height="450"
style="border:0;"
allowfullscreen=""
loading="lazy"
title="Al-Aqsa University Location"
></iframe>
Embedding Another Web Page
<!-- Embed another webpage -->
<iframe
src="https://www.example.com"
width="100%"
height="500"
title="Example Website"
></iframe>
Security Note
Be careful with iframes. Only embed content from trusted sources. Some websites block being embedded in iframes for security reasons (X-Frame-Options header). Never embed unknown or untrusted websites.
7. HTML Entities
HTML entities are special codes used to display reserved characters (like < and >) and special symbols that cannot be typed directly in HTML.
Why Do We Need Entities?
Some characters have special meaning in HTML. For example, < starts a tag. If you want to display the literal character < on your page, you must use its entity.
Common HTML Entities
| Character |
Entity Name |
Entity Number |
Description |
| < | < | < | Less than |
| > | > | > | Greater than |
| & | & | & | Ampersand |
| " | " | " | Double quote |
| ' | ' | ' | Single quote |
| | |   | Non-breaking space |
| © | © | © | Copyright |
| ® | ® | ® | Registered |
| ™ | ™ | ™ | Trademark |
| — | — | — | Em dash |
| – | – | – | En dash |
| « | « | « | Left guillemet |
| » | » | » | Right guillemet |
| € | € | € | Euro sign |
| £ | £ | £ | Pound sign |
Examples
<!-- Displaying HTML code as text -->
<p>In HTML, a paragraph is created with <p> and </p>.</p>
<!-- Copyright notice -->
<p>© 2026 Al-Aqsa University. All rights reserved.</p>
<!-- Multiple spaces (normally collapsed to one) -->
<p>Word1 Word2</p>
<!-- Trademark and registered -->
<p>Google™ Chrome®</p>
<!-- Ampersand in text -->
<p>Tom & Jerry</p>
8. Meta Tags
Meta tags provide metadata about the HTML document. They go in the <head> section and are not displayed on the page, but are used by browsers, search engines, and social media platforms.
Essential Meta Tags
<head>
<!-- Character encoding - always UTF-8 -->
<meta charset="UTF-8">
<!-- Responsive design - essential for mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Page description (shown in Google search results) -->
<meta name="description" content="Learn web development from scratch with HTML, CSS, and JavaScript tutorials at Al-Aqsa University.">
<!-- Keywords (less important for SEO now, but still used) -->
<meta name="keywords" content="HTML, CSS, JavaScript, web development, tutorial">
<!-- Author -->
<meta name="author" content="Al-Aqsa University">
<!-- Page title -->
<title>Web Development 1 - Al-Aqsa University</title>
</head>
Open Graph Meta Tags (Social Media)
Open Graph (og) tags control how your page appears when shared on Facebook, Twitter, LinkedIn, and other platforms.
<!-- Open Graph tags for social media sharing -->
<meta property="og:title" content="Web Development 1 Course">
<meta property="og:description" content="Learn HTML, CSS, and JS from scratch">
<meta property="og:image" content="https://example.com/course-preview.jpg">
<meta property="og:url" content="https://example.com/web-dev-1">
<meta property="og:type" content="website">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Web Development 1 Course">
<meta name="twitter:description" content="Learn HTML, CSS, and JS">
<meta name="twitter:image" content="https://example.com/preview.jpg">
Other Useful Meta Tags
<!-- Prevent search engines from indexing this page -->
<meta name="robots" content="noindex, nofollow">
<!-- Refresh page every 30 seconds -->
<meta http-equiv="refresh" content="30">
<!-- Theme color for mobile browsers -->
<meta name="theme-color" content="#00bcd4">
<!-- Favicon -->
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="apple-icon.png">
9. Accessibility Basics
Web accessibility means making websites usable by everyone, including people with disabilities (visual, auditory, motor, cognitive). In many countries, web accessibility is required by law.
Key Accessibility Practices
1. Alt Text on Images
Every <img> must have an alt attribute. Decorative images should have empty alt (alt="").
<!-- Meaningful image - describe what is shown -->
<img src="campus.jpg" alt="Al-Aqsa University main building with students walking">
<!-- Decorative image - empty alt so screen readers skip it -->
<img src="divider.png" alt="">
2. ARIA Labels
aria-label provides a text label for screen readers when the visual label is not sufficient.
<!-- Button with icon only (no visible text) -->
<button aria-label="Close dialog">X</button>
<!-- Search input -->
<input type="search" aria-label="Search articles" placeholder="Search...">
<!-- Navigation with aria-label to distinguish multiple navs -->
<nav aria-label="Main navigation">...</nav>
<nav aria-label="Footer navigation">...</nav>
3. The role Attribute
Defines the purpose of an element for assistive technologies. Semantic elements already have implicit roles, but sometimes you need to add them to generic elements.
<!-- Adding roles to non-semantic elements -->
<div role="banner">Header content</div>
<div role="navigation">Navigation links</div>
<div role="main">Main content</div>
<div role="alert">Important notification!</div>
<!-- Better: Just use semantic elements instead! -->
<header>Header content</header>
<nav>Navigation links</nav>
<main>Main content</main>
4. tabindex
Controls the tab order for keyboard navigation.
<!-- tabindex="0": element is focusable in normal tab order -->
<div tabindex="0">This div is now keyboard-focusable</div>
<!-- tabindex="-1": focusable by JavaScript, not by Tab key -->
<div tabindex="-1" id="error">Error message</div>
<!-- Avoid positive tabindex values (1, 2, 3...) -->
<!-- They override natural tab order and cause confusion -->
5. Skip Navigation Link
Allows keyboard users to skip the navigation and jump directly to the main content.
<body>
<!-- Skip link (hidden visually, visible to screen readers) -->
<a href="#main-content" class="skip-link">Skip to main content</a>
<header>
<nav>
<!-- lots of navigation links -->
</nav>
</header>
<main id="main-content">
<!-- Main page content -->
</main>
</body>
Accessibility Checklist
- All images have descriptive
alt text
- All form inputs have associated
<label> elements
- Use semantic HTML elements (
<header>, <nav>, <main>, etc.)
- Ensure sufficient color contrast
- Make the page navigable by keyboard (Tab, Enter, Escape)
- Provide skip navigation links
- Use heading hierarchy correctly (h1 through h6)
- Add
lang attribute to <html>
- Provide captions/subtitles for video content
10. Best Practices for Page Structure
Complete Semantic HTML Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Page description for SEO">
<title>Page Title - Site Name</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<!-- Skip Navigation -->
<a href="#main" class="skip-link">Skip to content</a>
<!-- Page Header -->
<header>
<h1>Site Name</h1>
<nav aria-label="Main navigation">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<!-- Main Content -->
<main id="main">
<article>
<header>
<h2>Article Title</h2>
<time datetime="2026-03-26">March 26, 2026</time>
</header>
<p>Article content...</p>
</article>
</main>
<!-- Sidebar -->
<aside>
<h3>Related</h3>
</aside>
<!-- Page Footer -->
<footer>
<p>© 2026 Site Name</p>
<address>
<a href="mailto:info@example.com">info@example.com</a>
</address>
</footer>
</body>
</html>
Summary of Rules
- Use semantic elements over generic
<div> and <span>
- Only one
<h1> and one <main> per page
- Always include
charset, viewport, title, and description
- Add
lang attribute to the <html> tag
- Use
alt text on all images
- Use
<label> for all form inputs
- Structure headings hierarchically (h1 > h2 > h3)
- Validate your HTML at validator.w3.org