HTML Tables
- HTML tables allow web developers to arrange data into rows and columns.
- The <table> tag defines an HTML table.
- Each table row is defined with a <tr> tag.
- Each table header is defined with a <th> tag.
- Each table data/cell is defined with a <td> tag.
- By default, the text in <th> elements are bold and centered.
- By default, the text in <td> elements are regular and left-aligned.
| Firstname | Lastname | Age |
|---|---|---|
| Jill | Smith | 50 |
| Eve | Jackson | 94 |
| Name | Telephone | |
|---|---|---|
| Bill Gates | 55577854 | 55577855 |
| Name: | Bill Gates |
|---|---|
| Telephone: | 55577854 |
| 55577855 |
HTML Images
- The HTML <img> tag is used to embed an image in a web page.
- The <img> tag is empty, it contains attributes only, and does not have a closing tag.
-
EX:
<img src="logo.png" alt="Logo" width="500"
height="600">
HTML picture Element
- The HTML <img> tag is used to embed an image in a web page.
- The <picture> element allows you to display different pictures for different devices or screen sizes.
- The <picture> element contains one or more <source> elements, each referring to different images through the srcset attribute. This way the browser can choose the image that best fits the current view and/or device.
- Each <source> element has a media attribute that defines when the image is the most suitable.
-
EX:
HTML Quotation and Citation Elements
Here is a quote from WWF's website:
For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.
WWF's goal is to: Build a future where people live in with nature.
The WHO was founded in 1948.
Written by John Doe.Visit us at:
Example.com
Box 564, Disneyland
USA
The Scream by Edvard Munch. Painted in 1893.
This text will be written from right to leftHTML Iframes
- The HTML <iframe> tag specifies an inline frame.
- An inline frame is used to embed another document within the current HTML document.
-
EX :
<iframe src="html1.html" height="300" width="100"
title="first session"></iframe>
Iframe - Target for a Link
-
An iframe can be used as the target frame for a link.
The target attribute of the link must refer to the name attribute of the iframe -
<iframe src="html1.html" name="iframe" width="100%" title="Iframe Example"></iframe>
<a href="html1.html" target="iframe">Show Iframe</a>
HTML Media
- Multimedia comes in many different formats. It can be almost anything you can hear or see, like images, music, sound, videos, records, films, animations, and more.
- Common Video Formats[The MP4, WebM, and Ogg formats are supported by HTML]
- Common Audio Formats[Only MP3, WAV, and Ogg audio are supported by the HTML standard.]
HTML Video
- The HTML <video> element is used to show a video on a web page.
-
EX:
<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> -
- The controls attribute adds video controls, like play, pause, and volume.
- The <source> element allows you to specify alternative video files which the browser may choose from. The browser will use the first recognized format.
- The text between the <video> and </video> tags will only be displayed in browsers that do not support the <video> element.
- To start a video automatically, use the autoplay attribute
- Add muted after autoplay to let your video start playing automatically (but muted)
- Example:
HTML Audio
- The HTML <Audio> element is used to show a Audio on a web page.
-
EX:
<audio controls>
<source src="movie.ogg" type="audio/ogg">
<source src="movie.mp3" type="audio/mp3">
Your browser does not support the video tag.
</audio> -
- The controls attribute adds audio controls, like play, pause, and volume.
- The <source> element allows you to specify alternative audio files which the browser may choose from. The browser will use the first recognized format.
- The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element.
- To start a audio automatically, use the autoplay attribute
- Add muted after autoplay to let your audio start playing automatically (but muted)
HTML YouTube Videos
To play your video on a web page, do the following:
- Upload the video to YouTube
- Take a note of the video id
- Define an <iframe> element in your web page
- Let the src attribute point to the video URL
- Use the width and height attributes to specify the dimension of the player
- Add any other parameters to the URL (see below)
-
Example:
<iframe width="560" height="315" src="https://www.youtube.com/embed/WucfckO0q48" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
HTML Attributes
- Attributes provide additional information about elements
- Attributes are always specified in the start tag
- Attributes usually come in name/value pairs like: name="value"
The href Attribute
- The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to
- EX: <a href="https://www.google.com/">Google</a>
The src && alt Attributes
- The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path to the image to be displayed
- The <img> tag is used to embed an image in an HTML page. The tag attribute specifies an alternate text for an image, if the image for some reason cannot be displayed. This can be due to slow connection, or an error in the src attribute, or if the user uses a screen reader.
- EX: <img src="logo.png" alt="Logo">
There are two ways to specify the URL
-
Absolute URL
Links to an external image that is hosted on another website. Example: src="https://getwallpapers.com/wallpaper/full/8/d/1/59198.jpg".
-
Relative URL
Links to an image that is hosted within the website. Here, the URL does not include the domain name. If the URL begins without a slash, it will be relative to the current page. Example: src="logo.jpg". If the URL begins with a slash, it will be relative to the domain. Example: src="/images/logo.jpg".
The width && height Attributes
- The <img> tag should also contain the width and height attributes, which specifies the width and height of the image (in pixels)
- EX: <img src="logo.png" alt="Logo" width="500" height="600">
The style Attribute
- The style attribute is used to add styles to an element, such as color, font, size, and more.
- EX: <h2 style="color:#007bff;"> This is H2 </h2>
HTML Block and Inline Elements
-
Block-level Elements
- A block-level element always starts on a new line.
- A block-level element always takes up the full width available.
- A block level element has a top and a bottom margin.
-
Here are the block-level elements in HTML:
<address> <article> <aside> <blockquote> <canvas> <div>
<footer> <form> <h1>-<h6> <header> <hr> <li>
<main> <nav> <ol> <p> <pre> <section> <table> <ul> <video> - The <div> element is often used as a container for other HTML elements.
-
Inline Elements
- An inline element does not start on a new line.
- An inline element only takes up as much width as necessary.
-
Here are the inline elements in HTML:
<a> <br> <b> <button> <i> <img>
<input> <label> <q>-<output> <object> <script> <select>
<small> <span> <strong> <sub> <sup> <textarea> <time> - The <span> element is an inline container used to mark up a part of a text, or a part of a document.