# HTML 103: Adding Favicons, Videos, and Audios to a Web Page

## Refresher Quiz

Let us see how well we remember the concepts from our previous article:

<details data-node-type="hn-details-summary"><summary>Question 1: What special HTML tag is used to preserve formatting such as spaces and line breaks within the text, making it appear exactly as written in the HTML code?</summary><div data-type="detailsContent"><strong>Answer:</strong> The <code>pre </code>tag is used to preserve the exact formatting of the text as it is written in the HTML code, including all spaces, line breaks, and indentation, which are typically not preserved when using standard HTML tags like <code>p</code> tags for paragraphs.</div></details><details data-node-type="hn-details-summary"><summary>Question 2: Why are comments added to HTML documents, and how do they impact the display of the webpage?</summary><div data-type="detailsContent"><strong>Answer:</strong> Comments in HTML are used for adding explanatory notes or reminders within the code that are not meant to be displayed on the web page. They serve as a guide for the developer or others who may work on the HTML document in the future, making the code easier to understand and maintain.</div></details><details data-node-type="hn-details-summary"><summary>Question 3: In HTML, how can you make a hyperlink open in a new browser tab instead of the current one?</summary><div data-type="detailsContent"><strong>Answer:</strong> By adding the <code>target="_blank"</code> attribute to an anchor <code>a</code> tag, you instruct the browser to open the hyperlink in a new tab. This is particularly useful for external links or ensuring that users do not lose their current page position.</div></details><details data-node-type="hn-details-summary"><summary>Question 4: What function does the 'title' attribute serve when used within an anchor tag in HTML?</summary><div data-type="detailsContent"><strong>Answer:</strong> The<code> title</code> attribute provides additional information about the hyperlink, typically displayed as a tooltip when the user hovers their mouse over the link. This can enhance usability and accessibility by giving users more context about the link's destination or purpose.</div></details><details data-node-type="hn-details-summary"><summary>Question 5: Explain the process of creating a hyperlink that directs to another webpage using HTML.</summary><div data-type="detailsContent"><strong>Answer:</strong> A hyperlink is created using the anchor <code>a </code>tag, where the <code>href</code> (hypertext reference) attribute specifies the destination URL of the link. The text or content placed between the opening and closing <code>a</code> tags becomes clickable and directs the user to the specified URL when clicked.</div></details><details data-node-type="hn-details-summary"><summary>Question 6: What role does the 'href' attribute play in anchor tags in HTML?</summary><div data-type="detailsContent"><strong>Answer:</strong> The <code>href</code> attribute in an anchor tag specifies the URL of the page the link points to. It is essential for defining the destination of the hyperlink, enabling users to navigate from one resource to another by clicking on the link.</div></details><details data-node-type="hn-details-summary"><summary>Question 7: How are absolute and relative links distinguished in HTML, and when might you use each type?</summary><div data-type="detailsContent"><strong>Answer:</strong> Absolute links provide the full URL path, including the protocol (http or https) and domain name, and are used to link to external sites. Relative links specify a path relative to the current document's location, useful for linking to resources within the same website without specifying the full URL, making site migration and structure changes easier to manage.</div></details><details data-node-type="hn-details-summary"><summary>Question 8: What is the correct way to control the display size of an image in HTML?</summary><div data-type="detailsContent"><strong>Answer:</strong> The display size of an image can be controlled using the <code>width</code> and <code>height</code> attributes within the <code>img</code> tag. Specifying these attributes allows developers to resize the image directly in the HTML, affecting how it is displayed on the webpage without altering the original image file.</div></details><details data-node-type="hn-details-summary"><summary>Question 9: How can developers include hidden notes or documentation within HTML code without affecting the webpage’s visual output?</summary><div data-type="detailsContent"><strong>Answer:</strong> Developers can include hidden notes or documentation within HTML code by using comments, denoted by <code>&lt;!-- to start the comment and -&gt;</code> to end it. This text is ignored by the browser when rendering the page, allowing for internal documentation or notes to be added without any impact on the page's layout or content seen by users.</div></details><details data-node-type="hn-details-summary"><summary>Question 10: Can you explain the differences between absolute and relative paths in HTML, providing examples as described in the article?</summary><div data-type="detailsContent"><strong>Answer:</strong> In HTML, paths are used to link to other documents or resources. An absolute path includes the complete URL, specifying the protocol, such as <strong>http://</strong> or <strong>https://</strong>, followed by the domain name and full path to the resource. For example, linking to a LinkedIn page with <code>&lt;a href="</code><a target="_blank" rel="noopener noreferrer nofollow" href="https://www.linkedin.com/in/ao111&quot;>Linkedin</a>" style="pointer-events: none"><code>https://www.linkedin.com/in/ao111"&gt;Linkedin&lt;/a&gt;</code></a> uses an absolute path because it provides the entire URL needed to access the resource from anywhere on the internet. Relative paths, on the other hand, specify a link in relation to the current document's location without the domain name. They're used for linking to resources within the same website. An example from the article is the link to the projects page: <code>&lt;a href="./assets/projects.html"&gt;Go to Projects&lt;/a&gt;</code>. This relative path starts with <strong>./</strong> indicating that the <code>projects.html</code> file is located in the <strong>assets</strong> directory, which is at the same level as the current document. This method makes it easier to manage links within a website since you don't need to update the domain name if it changes or when moving the site to a different domain.</div></details>

## Adding Favicons

A favicon or Favourite Icon is an image that appears as the icon of your website or webpage, displayed on the browser tab. Usually, a logo is used as the favicon of your webpage.

* First, get an image you wish to use and add it to your images folder. We will use the passport as our favicon.
    
* within the `head` section of our `index.html` document, create a pair of `link` tags just above the `title` tags.
    
* Notice that this is a self-closing tag, add an `href` attribute, and set its value to the relative path to the passport.
    
* Add a `type` attribute and set its value to `image/jpg` since the passport is an image file with a `.jpg` extension.
    
* Finally, add `rel` attribute and set its value to `icon`. Your code should look like this:
    

```html
<link href="./assets/images/passport.jpg" type="image/jpg" rel="icon">
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1711769075258/8fe050eb-1041-4933-91ee-44953405c46c.png align="left")

notice the favicon next to the web page’s title.

## Working with Video Files

You can add videos directly to your web page as follows:

* Create a `videos` folder inside your `assets` folder in vs code
    
* Find a video, representing a project you have done. You can get a free one from [canva.com](http://canva.com).
    
* In your `projects.html` file, create a new `projects` section right under your `project 1` and call it `project 2`, using a `h2` tag.
    
* Next, use a `video` tag the same way you used the `img` tag in `project 1` above. add a `src` attribute and set it to the relative path to the the video file.
    
* Change the width as desired by adding a width attribute and set the width to 400px.
    
* Add a `controls` attribute for the video to be able to be played.
    
* Add an `autoplay` attribute for the video to play automatically
    
* Add a `muted` attribute for the video to be muted by default to avoid distractions to users.
    
* Add a `loop` attribute for the video to loop back to beginning when finished.
    
* Give it a short description using a paragraph tag.
    
* You should know that you can turn any image or video file into a hyperlink by wrapping it in anchor tags and setting the `href` attribute to a url of choice. we will set our url to the source file in canva.
    
* Finally, have the link open in a new tab by setting the `target` attribute to `_blank`
    

```html
<h2>Project 2</h2>
<a href="<https://www.canva.com/design/DAGA8YG9y_w/7Ks8QYsEn-z3X8OTXu0LWA/edit>"><video src="../assets/videos/project 2.mp4" width="400px" controls autoplay muted loop target="_blank"></video></a>
<p>A very short video demo</p>
```

Here is the code as well as the live preview

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1711769431416/2d668fc5-28b5-49b9-b5ee-7b9732e35e84.png align="left")

## Activity h05:

## Adding Audio Files

We are going to add a few audio files to our profile:

* In our `index.html` file, add a new hobby to the hobbies section: “listening to music”
    
* Wrap this new hobby inside anchor tags and set the relative path to `./assets/music.html`. Remember to add a `target` attribute and set it to `_blank` to open in a new tab.
    
* to create this `music.html` file, inside your assets folder, create a `music.html` file.
    
* open this `music.html` file and create a boilerplate code.
    
* Title it `My Favourite Music`
    
* Using an `h2` tag, add a heading titled `My Favourite Music`
    
* I am pretty sure you have some audio files of music you listen to regularly, grab those files, create a folder called `music` inside your assets folder, and paste those songs in there.
    
* Right under the `h2` tag. create an `audio` tag and specify a source attribute to a relative path to the first song, then do the same for all the other songs, in separate audio tags.
    
* next create attributes for `controls`, `muted`, `autoplay` and `loop`.
    

Try this activity before checking the code on my project repo. check out the mock-up below.

You will realize that as we move on, I expect that you are getting better at this as I will no longer openly post code solutions to activities here. I will only place mock-ups and then push the codes to the repo. [Click here](https://github.com/accdev1694/Learn-HTML) for access to the repository.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1711769697388/ab6f6c0b-aa03-45c8-92dc-bd837a80fbc2.png align="left")

There you have it, You have Learned how to add Audio, Video, and a Favicon to your HTML Page.
