HTML Exam 4: Graphics, Advanced Media, and APIs (20 Challenges)
HTML Exam 4: Expert Level
This exam includes 20 advanced challenges focused on expert-level techniques.
Exercises 1-10: Beginner level |
Exercises 11-15: Intermediate level |
Exercises 16-20: Advanced level
Use SVG to draw a circle:
- Radius 40, centered at (50, 50).
- Fill it red.
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="red" />
</svg>
Use picture for responsive images:
- A small image for screens under 600px.
- A large image for bigger screens.
<picture>
<source media="(max-width: 600px)" srcset="img_small.jpg">
<img src="img_large.jpg" alt="Responsive image">
</picture>
Create a field that accepts exactly 10 digits:
<input type="text" pattern="[0-9]{10}" title="10 digits" required>
Create an input with suggestions:
<input list="browsers" name="browser">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
</datalist>
Display 70% progress:
<progress value="70" max="100">70%</progress>
Display storage 60/100:
<meter value="60" min="0" max="100">60%</meter>
Add subtitles to the video:
<video controls>
<source src="movie.mp4" type="video/mp4">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
</video>
Create an image map:
<img src="workplace.jpg" usemap="#workmap">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" href="computer.htm">
</map>
Use template for hidden content:
<template id="myTemplate">
<h2>Secret content</h2>
<p>Not visible on load</p>
</template>
Define a canvas sized 200x100:
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000"></canvas>
Draw an SVG rectangle sized 100x50:
<svg>
<rect width="100" height="50" fill="blue" />
</svg>
Create a dialog with a close button:
<dialog id="myDialog">
<p>Dialog content</p>
<button onclick="document.getElementById('myDialog').close()">Close</button>
</dialog>
Use time with datetime:
<time datetime="2024-01-01">January 1, 2024</time>
Use mark to highlight text:
<p>This <mark>highlighted text</mark> is in the paragraph.</p>
Use srcset for multiple resolutions:
<img src="image.jpg"
srcset="image-1x.jpg 1x, image-2x.jpg 2x"
alt="Responsive image">
Draw a rectangle on canvas using JavaScript:
<canvas id="myCanvas"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(10, 10, 100, 50);
</script>
Draw an SVG line using path:
<svg>
<path d="M10 10 L100 100" stroke="black" stroke-width="2" />
</svg>
Use localStorage to save data:
<script>
// Save
localStorage.setItem('name', 'Ahmed');
// Retrieve
var name = localStorage.getItem('name');
</script>
Get the user's location:
<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log(position.coords.latitude, position.coords.longitude);
});
}
</script>
Create a page that includes:
- Video with subtitles.
- Canvas for a simple drawing.
- Progress bar.
- Dialog for notifications.
<!DOCTYPE html>
<html>
<body>
<video controls>
<source src="video.mp4" type="video/mp4">
<track src="subs.vtt" kind="subtitles" srclang="en">
</video>
<canvas id="canvas" width="200" height="100"></canvas>
<progress value="50" max="100"></progress>
<dialog id="notification">
<p>Important notification!</p>
<button onclick="this.parentElement.close()">Close</button>
</dialog>
</body>
</html>