HTML Iframes

An <iframe> is an HTML element that allows you to embed another HTML document within the current document. It is often used to embed external resources such as videos, maps, and interactive content into a web page.

Here is an example of how to use an <iframe> element:

<iframe src="https://www.example.com" width="600" height="400"></iframe>

This example will embed the webpage at “https://www.example.com” into the current HTML document, with a width of 600 pixels and a height of 400 pixels.

You can also use the srcdoc attribute to specify the HTML content to be embedded, instead of an external URL:

<iframe srcdoc="<h1>Hello, World!</h1>" width="600" height="400"></iframe>

In this example, the text “Hello, World!” will be displayed inside the iframe.

Note that iframes can be a security risk if they are used to embed untrusted content, as the embedded content has the same privileges as the main page and can potentially access sensitive information. It is important to only embed trusted content using iframes.

For more information about the <iframe> element and other HTML embedding elements, you can refer to the following resources:

HTML5 New Elements

New Added Elements in HTML 5:

  • <article>: The <article> tag is used to represent an article. More specifically, the content within the <article> tag is independent from the other content of the site (even though it can be related).
  • <aside>: The <aside> tag is used to describe the main object of the web page in a shorter way like a highlighter. It basically identifies the content that is related to the primary content of the web page but does not constitute the main intent of the primary page. The <aside> tag contains mainly author information, links, related content and so on.
  • <figcaption>: The <figurecaption> tag in HTML is used to set a caption to the figure element in a document.
  • <figure>: The <figure> tag in HTML is used to add self-contained content like illustrations, diagrams, photos or codes listing in a document. It is related to main flow but it can be used in any position of a document and the figure goes with the flow of the document and if remove it then it should not affect the flow of the document.
  • <header>: It contains the section heading as well as other content, such as a navigation links, table of contents, etc.
  • <footer>: The <footer> tag in HTML is used to define a footer of HTML document. This section contains the footer information (author information, copyright information, carriers etc). The footer tag are used within body tag. The <footer> tag is new in the HTML 5. The footer elements require a start tag as well as an end tag.
  • <main>: Delineates the main content of the body of a document or web app.
  • <mark>: The <mark> tag in HTML is used to define the marked text. It is used to highlight the part of the text in the paragraph.
  • <nav>: The <nav> tag is used to declaring the navigational section in HTML documents. Websites typically have sections dedicated to navigational links, which enables user to navigate the site. These links can be placed inside a nav tag.
  • <section>: It demarcates a thematic grouping of content.
  • <details>: The <details> tag is used for the content/information which is initially hidden but could be displayed if the user wishes to see it. This tag is used to create interactive widget which user can open or close it. The content of details tag is visible when open the set attributes.
  • <summary>: The <summary> tag in HTML is used to define a summary for the <details> element. The <summary> element is used along with the <details> element and provides a summary visible to the user. When the summary is clicked by the user, the content placed inside the <details> element becomes visible which was previously hidden. The <summary> tag was added in HTMl 5. The <summary> tag requires both starting and ending tag.
  • <time>: The <time> tag is used to display the human-readable data/time. It can also be used to encode dates and times in a machine-readable form. The main advantage for users is that they can offer to add birthday reminders or scheduled events in their calender’s and search engines can produce smarter search results.
  • <bdi>: The <bdi> tag refers to the Bi-Directional Isolation. It differentiate a text from other text that may be formatted in different direction. This tag is used when a user generated text with an unknown directions.
  • <wbr>: The <wbr> tag in HTML stands for word break opportunity and is used to define the position within the text which is treated as a line break by the browser. It is mostly used when the used word is too long and there are chances that the browser may break lines at the wrong place for fitting the text.
  • <datalist>: The <datalist> tag is used to provide autocomplete feature in the HTML files. It can be used with input tag, so that users can easily fill the data in the forms using select the data.
  • <keygen>: The <keygen> tag in HTML is used to specify a key-pair generator field in a form. The purpose of <keygen> element is to provide a secure way to authenticate users. When a from is submitted then two keys are generated, private key and public key. The private key stored locally, and the public key is sent to the server. The public key is used to generate client certificate to authenticate user for future.
  • <output>: The <output> tag in HTML is used to represent the result of a calculation performed by the client-side script such as JavaScript.
  • <progress>: It is used to represent the progress of a task. It is also define that how much work is done and how much is left to download a things. It is not used to represent the disk space or relevant query.
  • <svg>: It is the Scalable Vector Graphics.
  • <canvas>: The <canvas> tag in HTML is used to draw graphics on web page using JavaScript. It can be used to draw paths, boxes, texts, gradient and adding images. By default it does not contains border and text.
  • <audio>: It defines the music or audio content.
  • <embed>: Defines containers for external applications (usually a video player).
  • <source>: It defines the sources for <video> and <audio>.
  • <track>: It defines the tracks for <video> and <audio>.
  • <video>: It defines the video content.

HTML Video

To add a video to an HTML page, you can use the <video> element. This element allows you to embed video files into your web page and customize the way they are displayed.

Here is an example of how to use the <video> element:

<video src="myvideo.mp4" width="320" height="240" controls></video>

This example will embed a video file called “myvideo.mp4” into the HTML page, with a width of 320 pixels and a height of 240 pixels. The “controls” attribute adds video controls (play/pause, volume, etc.) to the video player.

You can also use the <source> element to specify multiple sources for the video, in case the browser does not support the first format:

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

In this example, the browser will try to play the MP4 file first, and if it is not supported, it will try the WEBM file. If neither file is supported, the text “Your browser does not support the video tag.” will be displayed.

For more information about the <video> element and other HTML media elements, you can refer to the following resources:

CSS Introduction

CSS (Cascading Style Sheets) is a stylesheet language that is used to describe the appearance and layout of a document written in HTML or XML. It allows you to apply styles, such as colors, fonts, and layouts, to your web pages in a separate file, called a stylesheet, which makes it easier to maintain and update your site’s design.

CSS works by matching elements in your HTML or XML document with rules in your stylesheet. Each rule consists of a selector, which specifies the elements to which the styles should be applied, and a declaration block, which contains one or more declarations that specify the styles to be applied.

For example, you can use the following CSS rule to make all <h1> elements blue and center-aligned:

Copy codeh1 {
  color: blue;
  text-align: center;
}

You can apply this rule to your HTML document by linking to the stylesheet using the <link> element in the <head> of the document:

Copy code<head>
  <link rel="stylesheet" href="/styles.css">
</head>

You can also apply styles directly to an HTML element using the style attribute:

Copy code<h1 style="color: blue; text-align: center;">This is a heading</h1>

CSS has a wide range of properties and features that allow you to customize the appearance and layout of your web pages. You can learn more about CSS and how to use it in your web development projects by consulting the documentation on the W3C website or by searching online for tutorials and resources.

HTML5 Web Worker

A Web Worker is a part of the HTML5 standard that allows web applications to run background tasks in a separate thread, without interfering with the main UI thread. This can be useful for tasks that are computationally intensive or that take a long time to complete, as it allows the application to remain responsive while the tasks are being executed.

To use Web Workers in your web application, you need to create a worker script that contains the code that you want to run in the background. The worker script is a separate JavaScript file that is loaded and executed by the main UI thread.

Here is an example of a simple worker script that calculates the sum of an array of numbers:

// Worker script
self.addEventListener("message", function(event) {
  const numbers = event.data;
  let sum = 0;
  for (let i = 0; i < numbers.length; i++) {
    sum += numbers[i];
  }
  self.postMessage(sum);
});

To start the worker, you can use the Worker constructor in JavaScript:

Copy codeconst worker = new Worker("worker.js");

You can then use the postMessage() method to send data to the worker and the onmessage event to receive data from the worker:

// Send data to worker
worker.postMessage([1, 2, 3, 4, 5]);

// Receive data from worker
worker.onmessage = function(event) {
  console.log("Sum:", event.data);
};

You can learn more about Web Workers and how to use them in your web development projects by consulting the documentation on the W3C website or by searching online for tutorials and resources.

HTML5 Application Cache

The HTML5 Application Cache (also known as the AppCache) is a mechanism that allows web applications to cache their resources (such as HTML, CSS, and JavaScript files) locally in the user’s browser. This allows the application to work offline or with a poor network connection, as the resources are loaded from the cache instead of being fetched from the server.

To use the Application Cache, you need to create a cache manifest file that lists the resources that should be cached. The manifest file is a simple text file with a .appcache extension that is linked to the HTML file using the manifest attribute of the <html> element:

<html manifest="/cache.appcache">
  ...
</html>

Here is an example of a simple cache manifest file:

CACHE MANIFEST
# version 1.0

CACHE:
index.html
style.css
script.js

NETWORK:
*

This manifest file specifies that the index.html, style.css, and script.js files should be cached, while all other resources should be fetched from the network.

When the user visits the application, the browser downloads the manifest file and caches the listed resources. Subsequent visits to the application will use the cached resources unless the manifest file has changed.

You can learn more about the HTML5 Application Cache and how to use it in your web development projects by consulting the documentation on the W3C website or by searching online for tutorials and resources.

HTML5 Web Storage

The HTML5 Web Storage feature allows web applications to store data locally in the user’s browser. It provides two mechanisms for storing data: session storage and local storage.

Session storage is a storage mechanism that is available for the duration of a single-page session. It is deleted when the user closes the browser window or tab.

Local storage is a storage mechanism that persists even after the browser window or tab is closed.

Both session storage and local storage provide a simple key-value storage mechanism, similar to cookies. However, they are more efficient and have larger storage limits than cookies.

To use Web Storage in your web application, you can use the sessionStorage and localStorage objects in JavaScript. These objects provide methods for storing, retrieving, and deleting data.

Here is an example of how to store and retrieve data using Web Storage:

// Store data
localStorage.setItem("key", "value");

// Retrieve data
const value = localStorage.getItem("key");

You can also use the removeItem() method to delete data from storage:

localStorage.removeItem("key");

You can learn more about the HTML5 Web Storage feature and how to use it in your web development projects by consulting the documentation on the W3C website or by searching online for tutorials and resources.

HTML5 Canvas vs. SVG

Both the HTML5 <canvas> element and Scalable Vector Graphics (SVG) are technologies that allow you to create graphics on the web. However, they have some differences in terms of their capabilities and how they work.

The <canvas> element is a raster graphics API that provides a drawing surface for rendering 2D graphics, such as charts, diagrams, and games. It is a lightweight and versatile alternative to using images or Flash for rendering graphics on the web.

SVG is a vector graphics format that uses a simple XML-based format to define graphics. It is ideal for creating scalable graphics, such as logos, icons, and diagrams, as the graphics can be resized without losing quality.

One key difference between <canvas> and SVG is that <canvas> is a bitmap (raster) graphics API, while SVG is a vector graphics API. This means that <canvas> graphics are created pixel by pixel, while SVG graphics are created using mathematical calculations. As a result, SVG graphics are usually more scalable and smaller in file size than <canvas> graphics.

Another difference is that <canvas> graphics are drawn using JavaScript, while SVG graphics can be drawn using either JavaScript or the declarative <path> element in HTML. This means that SVG graphics can be created and styled using both JavaScript and CSS, while <canvas> graphics can only be created and styled using JavaScript.

In general, <canvas> is a good choice for creating dynamic, interactive graphics, such as games and data visualizations, while SVG is

HTML5 SVG

Scalable Vector Graphics (SVG) is a part of the HTML5 standard that allows you to create vector graphics, such as charts, diagrams, and icons, on the web. It uses a simple XML-based format that can be easily edited and styled using CSS.

To use SVG in an HTML file, you can use the <svg> element to define the graphics container and the <path> element to define the shapes and lines that make up the graphic. You can then use the d attribute of the <path> element to define the path data using a series of commands and coordinates.

Here is an example of an SVG graphic that draws a red triangle:

<svg width="100" height="100">
  <path d="M 10,10 L 90,90 L 10,90 Z" fill="red" />
</svg>

This example defines a container with a width and height of 100 pixels and a <path> element that draws a triangle using the “move to”, “line to”, and “close path” commands. The fill attribute is used to set the fill color to red.

You can also use CSS to style and animate SVG graphics. For example, you can use the fill, stroke,

HTML5 Drag and Drop

The HTML5 Drag and Drop (DnD) feature allows users to drag and drop elements within a web page or between web pages. It is a part of the HTML5 standard and is implemented using the draggable attribute and the ondrag, ondragstart, and ondrop event attributes.

To make an element draggable, you can set the draggable attribute to true:

<div draggable="true">Drag me!</div>

To handle the drag and drop events, you can use the ondrag, ondragstart, and ondrop attributes to specify JavaScript event handlers:

<div id="drag-source" draggable="true" ondragstart="dragStartHandler(event)">
  Drag me!
</div>
<div id="drop-target" ondrop="dropHandler(event)" ondragover="dragOverHandler(event)">
  Drop here!
</div>

In this example, the dragStartHandler() function is called when the drag starts, the dragOverHandler() function is called when the dragged element is over the drop target, and the dropHandler() function is called when the element is dropped.

Here is an example of how you can implement the dragStartHandler() function:

function dragStartHandler(event) {
  event.dataTransfer.setData("text/plain", event.target.id);
  event.dataTransfer.effectAllowed = "move";
}

This function sets the data that will be transferred when the element is dropped and sets the allowed drag effect to “move”.

You can learn more about the HTML5 Drag and Drop feature and how to use it in your web development projects by consulting the documentation on the W3C website or by searching online for tutorials and resources.