HTML Tutorial Part 4: Audio, Video, Graphics, Web APIs, Accessibility and Interview Prep
Lessons 31 to 38 of 38. Embed audio and video, draw with canvas and SVG, use Web Storage and Geolocation, make pages accessible, and prepare for HTML interviews.
In this part
8. Multimedia and Graphics
- 31. Audio, Video and iframes (<video>, <audio>, <iframe>)
Embedding songs, movies and YouTube videos on a website - 32. Canvas vs SVG (<canvas> vs <svg>)
The difference between vector graphics (SVG) and a pixel drawing board (Canvas)
9. Modern Web APIs
- 33. Web Storage API (LocalStorage vs SessionStorage)
Keeping data in the browser permanently - 34. Geolocation API (Geolocation API - GPS Location)
Finding the Latitude and Longitude with the user's permission
10. Accessibility and Tools
- 35. Web Accessibility (Accessibility / a11y Standards)
Websites accessible to people with disabilities and to screen readers - 36. HTML Entities and Symbols (Entities, Symbols & Emojis)
Special symbols: copyright ©, rupee ₹ and safe brackets - 37. HTTP Methods and Status Codes (HTTP Methods & Codes)
The meaning of GET, POST, 200, 301, 403, 404, 500 - 38. Top 3 Interview Questions and Study Plan (Interview Q&A)
The top questions asked in job interviews and their precise answers
8. Multimedia and Graphics
31. Audio, Video and iframes (<video>, <audio>, <iframe>)
Embedding songs, movies and YouTube videos on a website
Real-life analogy
Before HTML5, playing video needed third-party apps like the Flash player. Now HTML5 has a built-in TV screen!
Explanation
1. HTML Video & Audio:
<video controls>: To play a video with play/pause buttons.<audio controls>: To play audio.- Attributes:
autoplay,loop,muted,poster="thumb.jpg".
2. YouTube Embedding: With the <iframe> tag you can embed YouTube videos without putting any load on your server.
Golden rules
- Be sure to add the
controlsattribute on video and audio tags, otherwise the user will not see the play/pause button. - If you want to
autoplaya video, it is also necessary to addmutedalong with it.
Common mistake
Forgetting to write controls, so the video appears on screen but there is no button to start it.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<h4 style="margin-top: 0;">1. Audio Player (<audio controls>):</h4>
<audio controls style="width: 100%; max-width: 280px;">
<source src="https://www.w3schools.com/html/horse.mp3" type="audio/mpeg">
Your browser does not support audio.
</audio>
<h4 style="margin-top: 15px;">2. YouTube Video (Iframe Embed):</h4>
<iframe width="100%" height="160" style="max-width: 280px; border-radius: 6px;"
src="https://www.youtube.com/embed/dQw4w9WgXcQ"
frameborder="0" allowfullscreen>
</iframe>
</body>
</html>
Quick quiz
Which attribute has to be added to a video tag to show play, pause and volume slider?
- buttons
- player
- controls
- playbar
Show answer
Answer: controls
The controls attribute gives the user play, pause and volume controls.
32. Canvas vs SVG (<canvas> vs <svg>)
The difference between vector graphics (SVG) and a pixel drawing board (Canvas)
Real-life analogy
SVG is like a picture drawn on a rubber balloon that never breaks up (Pixelate) no matter how much you enlarge it. Canvas is a blank drawing sheet on which pictures are drawn with the brush of JavaScript.
Explanation
SVG (Scalable Vector Graphics): XML-based lines, circles and shapes. They run on mathematical calculation, so they never break up even on 4K or 8K displays. Best for logos and icons.
Canvas (<canvas>): A pixel-based blank board. Lines and animations are drawn on it through JavaScript (getContext('2d')). Best for web games and charts.
Golden rules
- Always use SVG for logos and icons.
- JavaScript is required to draw anything on a canvas.
Common mistake
Using a heavy PNG photo for a logo. A light and scalable SVG should be used instead.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<h4>1. Pure SVG (star):</h4>
<svg width="50" height="50" viewBox="0 0 24 24" fill="#f59e0b">
<polygon points="12,2 15,9 22,9 17,14 19,21 12,17 5,21 7,14 2,9 9,9"/>
</svg>
<h4 style="margin-top: 10px;">2. HTML Canvas (JS render):</h4>
<canvas id="myCanvas" width="160" height="50" style="border:1px solid #cbd5e1; border-radius: 4px;"></canvas>
<script>
const c = document.getElementById("myCanvas");
const ctx = c.getContext("2d");
ctx.fillStyle = "#10b981";
ctx.fillRect(10, 10, 140, 30);
ctx.fillStyle = "white";
ctx.font = "bold 12px sans-serif";
ctx.fillText("Canvas Drawn!", 30, 30);
</script>
</body>
</html>
Quick quiz
Which graphic format never gets pixelated no matter how much you zoom in?
- JPEG
- PNG
- SVG
- GIF
Show answer
Answer: SVG
SVG (Scalable Vector Graphics) works on mathematical lines, so it never breaks up.
9. Modern Web APIs
33. Web Storage API (LocalStorage vs SessionStorage)
Keeping data in the browser permanently
Real-life analogy
Web Storage is the browser's own small digital safe in which your name and login token stay locked, even if you close the browser and open it again!
Explanation
Storage that is many times faster and safer than Cookies:
- LocalStorage: Data kept in it is never deleted unless the user clears the browser history themselves.
- SessionStorage: Data kept in it lasts only as long as that particular tab is open. The data is gone as soon as the tab is closed.
- Syntax:
localStorage.setItem("key", "value")andlocalStorage.getItem("key").
Golden rules
- Only string (Text) data can be stored safely in local storage.
Common mistake
Saving a user's password in local storage (this is insecure).
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<div style="border: 1px solid #cbd5e1; padding: 12px; border-radius: 6px; background: #f8fafc;">
<h4 style="margin: 0 0 6px 0; color: #0284c7;">The Magic of Local Storage:</h4>
<input type="text" id="userInput" placeholder="Enter your name..." style="padding: 4px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12px;">
<button onclick="save()" style="background: #0284c7; color: white; border: none; padding: 5px 10px; border-radius: 4px; font-size: 12px; cursor: pointer;">Save</button>
<p id="msg" style="margin: 6px 0 0 0; font-size: 12px; font-weight: bold; color: #059669;"></p>
</div>
<script>
function save() {
const v = document.getElementById('userInput').value;
localStorage.setItem('myDemoName', v);
load();
}
function load() {
const s = localStorage.getItem('myDemoName');
if (s) document.getElementById('msg').innerText = "Saved name: " + s;
}
load();
</script>
</body>
</html>
Quick quiz
Which API stores data in the browser permanently, without expiry?
- SessionStorage
- LocalStorage
- CookieStorage
- DataSaver
Show answer
Answer: LocalStorage
Data kept in LocalStorage stays safe even after the browser is closed.
34. Geolocation API (Geolocation API - GPS Location)
Finding the Latitude and Longitude with the user's permission
Real-life analogy
Just as the Zomato or Google Maps app finds your address by itself the moment you open it, this API does the same thing.
Explanation
The HTML5 Geolocation API allows you to find the GPS location of the user's device:
- Function:
navigator.geolocation.getCurrentPosition(success, error) - Security rule: Location works only over a secure HTTPS connection.
- The browser shows the user a popup: "Do you want to give this site your location?" The location is obtained only if the user clicks Allow.
Golden rules
- Always add error handling (in case the user refuses to give the location).
Common mistake
Testing location over local HTTP (it gets blocked).
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<button onclick="getLoc()" style="background: #059669; color: white; border: none; padding: 8px 14px; border-radius: 4px; font-size: 13px; font-weight: bold; cursor: pointer;">
Find my location (GPS)
</button>
<p id="locOutput" style="font-size: 13px; color: #334155; margin-top: 10px;"></p>
<script>
function getLoc() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(pos) => {
document.getElementById('locOutput').innerHTML =
"Latitude (Lat): " + pos.coords.latitude + "<br>Longitude (Long): " + pos.coords.longitude;
},
(err) => {
document.getElementById('locOutput').innerText = "Error: permission was not granted.";
}
);
}
}
</script>
</body>
</html>
Quick quiz
Which condition is mandatory for the Geolocation API to get the user's location?
- The website being paid
- The user granting Allow permission
- Bluetooth being on
- Being logged in to Google
Show answer
Answer: The user granting Allow permission
No website can get the location without the user's explicit permission.
10. Accessibility and Tools
35. Web Accessibility (Accessibility / a11y Standards)
Websites accessible to people with disabilities and to screen readers
Real-life analogy
Just as public buildings have ramps for wheelchairs alongside stairs, accessibility on a website gives every person the freedom to use the internet.
Explanation
Accessibility (a11y) means building a website so that visually impaired or physically disabled people can also understand your website with the help of a screen reader:
- Alt Text: Add a clear and meaningful
altto every image. - Form Labels: Add
<label for="">to every input box. - Semantic Tags: Don't make a click-only
<div>in place of a<button>, because a keyboard user cannot reach the div by pressing Tab.
Golden rules
- Always use a real
<button>or<a>tag for clickable things.
Common mistake
Building a website that works only with a mouse. A good website should work fully with the keyboard's Tab and Enter keys as well.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<form>
<label for="uEmail" style="font-weight: bold; font-size: 13px; display: block; margin-bottom: 4px;">
Email address (the screen reader will read this aloud):
</label>
<input type="email" id="uEmail" placeholder="name@example.com"
style="padding: 6px; width: 100%; max-width: 260px; border: 1px solid #64748b; border-radius: 4px;">
<br><br>
<button type="submit" style="background: #0f172a; color: white; padding: 6px 12px; border-radius: 4px; cursor: pointer;">Submit</button>
</form>
</body>
</html>
Quick quiz
Why is Accessibility abbreviated as 'a11y'?
- Because it is a 11th-grade subject
- Because there are 11 letters between 'a' and 'y'
- It is the name of a piece of software
- There is no reason
Show answer
Answer: Because there are 11 letters between 'a' and 'y'
In the word 'Accessibility', there are exactly 11 letters between the first letter 'a' and the last 'y'.
36. HTML Entities and Symbols (Entities, Symbols & Emojis)
Special symbols: copyright ©, rupee ₹ and safe brackets
Real-life analogy
Since < and > are reserved in HTML for creating tags, secret codes (Entities) are used to print real brackets on screen.
Explanation
Major HTML Entities:
< : < (Less than)> : > (Greater than)& : & (Ampersand)© : © (Copyright)₹ : ₹ (rupee sign) : non-breaking spaceGolden rules
- An entity code always starts with
&and ends with;.
Common mistake
Forgetting to put the semicolon (;) at the end.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px; font-size: 13px;">
<p>Copyright symbol: <strong>© 2026</strong></p>
<p>Indian currency: <strong>₹ 5,000</strong></p>
<p>Showing code on screen: <strong><div class="box"></strong></p>
</body>
</html>
Quick quiz
Which entity is used in HTML to give a non-breaking space between two words?
- &space;
-
- ␣
- ⪆
Show answer
Answer:
&nbsp; stands for Non-Breaking Space.
37. HTTP Methods and Status Codes (HTTP Methods & Codes)
The meaning of GET, POST, 200, 301, 403, 404, 500
Real-life analogy
Think of a restaurant: GET is looking at the menu card, POST is ordering food, and 404 is the waiter saying 'Sorry, this dish is finished!'
Explanation
1. Main HTTP methods:
GET: Retrieving data from the server.POST: Sending new data to the server.
2. Main status codes:
200 OK: Successful301 Moved: Page permanently moved403 Forbidden: No permission404 Not Found: Page not found500 Server Error: Server faultGolden rules
- Always use POST in a login form.
Common mistake
Getting confused between 404 and 500 errors. 404 is the user's mistake, 500 is the server developer's mistake.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px; text-align: center;">
<div style="padding: 20px; border: 2px solid #ef4444; border-radius: 8px; background: #fef2f2; max-width: 280px; margin: auto;">
<h1 style="color: #dc2626; font-size: 32px; margin: 0;">404</h1>
<h4 style="color: #991b1b; margin: 4px 0;">Page Not Found</h4>
<p style="font-size: 11px; color: #7f1d1d;">The requested page does not exist on the server.</p>
</div>
</body>
</html>
Quick quiz
When a file or page is not found on a website, which error code does the browser show?
- 200
- 301
- 404
- 500
Show answer
Answer: 404
404 Not Found means that the requested page does not exist on the server.
38. Top 3 Interview Questions and Study Plan (Interview Q&A)
The top questions asked in job interviews and their precise answers
Real-life analogy
An interviewer doesn't check how many tags you have memorised; they check whether or not you know how to write clean, modern and secure code.
Explanation
The top 3 most frequently asked questions:
Golden rules
- Always keep proper indentation in your code.
Common mistake
Saying in an interview that 'HTML is a programming language'. Always say that it is a markup language.
Example code
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; padding: 20px;">
<div style="border-left: 4px solid #10b981; padding-left: 12px;">
<h3 style="color: #065f46; margin: 0;">Congratulations! The entire HTML course is complete! 🎉</h3>
<p style="font-size: 13px; color: #334155; margin-top: 4px;">
Now you can build a complete, responsive and semantic web page on your own.
</p>
</div>
</body>
</html>
Quick quiz
Which of these is an example of an 'Empty Tag' (self-closing tag)?
- <p>
- <div>
- <br>
- <h1>
Show answer
Answer: <br>
<br> has no closing tag, so it is an Empty Tag.