Day 6: Media, Multipages & Deployment


First Principle: The Web is More Than Just Text and Images

Webpages aren’t just about words and pictures. They should also handle videos, songs, and other media. Earlier, this was a big problem—playing a video or audio required extra plugins like Flash, QuickTime, or Silverlight. These were messy, unsafe, and didn’t always work everywhere.

The Core Problem

How do we add video and audio to a webpage in a way that is:

The Solution: The HTML5 <video> and <audio> Tags

HTML5 gave us two special tags:

No extra plugins needed—just pure HTML.




Part 1: Adding a Video

The main tag is <video>. At the very least, it needs the video file path.

        <!-- The simplest example -->
        <video src="my-awesome-video.mp4"></video>
        

Problem:

If you use only this, the video just shows a still image (first frame). You can’t play or pause it—it’s useless as a player.

The controls Attribute: The Built-In Player

To make it an actual video player, we add the controls attribute. This instantly gives us play, pause, volume, and fullscreen buttons.

        <video src="my-awesome-video.mp4" controls></video>
        



Part 2: More Control with Attributes

Now that we can add a video, let’s learn how to control its size, behavior, and look.

        <video src="video.mp4" width="640" height="360" controls></video>
        
        <!-- This will autoplay silently -->
        <video src="video.mp4" autoplay muted controls></video>
        
        <video src="video.mp4" poster="images/video-thumbnail.jpg" controls></video>
        



Part 3: The <audio> Tag

The <audio> tag works almost the same as <video>, but it’s for sound files like songs, podcasts, or sound effects.

Just add the controls attribute to get a play/pause/volume bar.

        <p>Listen to our theme song:</p>
        <audio src="audio/theme-song.mp3" controls></audio>
        

Result:

The user gets a built-in audio player with all the basic controls.




Part 4: Advanced & Professional - Real-World Problems

So far, we’ve learned how to play videos and audio, but in the real world, there are bigger challenges:

Problem #1: Not all browsers support the same video format

If you only provide one file type, some users won’t be able to watch your video.

Solution: Use the <source> element

Instead of giving just one src on the <video> tag, you can add multiple tags inside. The browser will check them in order and play the first one it support

        <video controls poster="images/thumbnail.jpg">
            <source src="videos/my-video.webm" type="video/webm">
            <source src="videos/my-video.mp4" type="video/mp4">
            Sorry, your browser doesn’t support embedded videos.
        </video>
        

This is the professional way to add videos.

The type attribute tells the browser what format it is before trying to load it.

Problem #2: Accessibility (Making Videos Inclusive)

What about users who:

They need captions or subtitles

Solution: Use the element

This tag lets you add captions, subtitles, or descriptions.

It usually links to a .vtt (WebVTT) file.

        <video controls>
            <source src="video.webm" type="video/webm">
            <source src="video.mp4" type="video/mp4">

            <!-- English Captions -->
            <track src="captions_en.vtt" kind="captions" srclang="en" label="English">

            <!-- Spanish Subtitles -->
            <track src="subtitles_es.vtt" kind="subtitles" srclang="es" label="Español">
        </video>

        

Breakdown of attributes:

This makes your media accessible to more people, which is a key part of professional web development.




The Robust & Professional Method (<source>)

        <video width="320" height="240" controls>
            <source src="movie.mp4" type="video/mp4">
            <source src="movie.ogg" type="video/ogg">
            Your browser does not support the video tag.
        </video>
        

Purpose: To ensure maximum browser compatibility.

The First Principle:

Not all browsers support the same video file formats.

How It Works (The Logic):

  1. Browser checks <source src="movie.mp4" ...>
  1. Browser checks <source src="movie.ogg" ...>

The Fallback Text:

If the browser is too old (e.g., IE8, which doesn’t even know <video>), it will show:

Your browser does not support the video tag. Summary (Example 1):

Example 2: The Simple & Direct Method (src attribute)

        <video src="a.mp4" controls></video>
        
Purpose: Simplicity and directness.

How It Works (The Logic):

Summary (Example 2):

Conclusion: Which Video Method Should You Use?

If you’re building a professional or public-facing website, the preferred method is to use the element. It’s considered best practice since it ensures maximum compatibility across browsers by offering multiple video formats.

That said, because .mp4 is now supported almost everywhere, many developers choose the simpler shortcut — adding the src directly on the <video> tag. This works fine for smaller or internal projects, but there’s always a slight risk that it won’t play on every device or browser.

Creating the Copyright Symbol ©

In HTML, you can display the copyright symbol using either an entity name or an entity number. Both render identically, but the entity name is usually easier to remember.

  1. Using the Entity Name (Recommended)

    This is the most common and human-readable way.

    Code: &copy;

    Example in a footer:
                    <footer>
    <p>Copyright &copy; 2024 My Awesome Website. All Rights Reserved.</p>
    </footer>
    Browser output:

    Copyright © 2024 My Awesome Website. All Rights Reserved.

  2. Using the Entity Number

    This approach uses the numeric code for the symbol. It works the same but is less intuitive.

    Code: &#169;

    Example in a footer:
                    <footer>
    <p> &#169; 2024 My Awesome Website. All Rights Reserved.</p>
    </footer>
    Browser output:

    Copyright © 2024 My Awesome Website. All Rights Reserved.




Other Common Symbol Entities You Should Know

The table below shows some frequently used HTML entities (both the name and the numeric code):

Symbol Description Entity Name (code shown) Entity Number (code shown)
© Copyright &copy; &#169;
® Registered Trademark &reg; &#174;
Trademark &trade; &#8482;
< Less-than (used to show code) &lt; &#60;
> Greater-than (used to show code) &gt; &#62;
& Ampersand &amp; &#38;
" Double Quote &quot; &#34;
Euro Sign &euro; &#8364;