HTML Interview Questions


Q6: Describe the server-sent events in HTML5?

Ans: Server-sent events are those that are forwarded to the browser from the webserver. With the aid of these events, it is possible to update the DOM elements continuously. This is exactly what gives it extra points over straight-up polling.

In polling, you have to deal with lots of overhead. The reason behind this is that the HTTP connection is short-lived and keeps tearing down. On the other hand, in server-sent events, there is one HTTP connection that goes a long way. If you prefer to use a server-sent event. You have to use the < eventsource > element. This element identifies the URL that transfers the data stream containing the events.

Q7: Define Web Workers?

Ans: Web workers are effective to save your time as their addition enables parallelism and async capability. Although it runs in the background to perform computationally exhaustive tasks, you can observe the results on the page evidently. It makes the web page responsive. You can successfully do it by initiating a separate thread for such tasks.

They can’t perform UI operations, so you must not use them for it. There are three types of web workers. dedicated workers are used by a single script, shared workers are used by various scripts, and service workers serve as proxy servers.

Q8: Define raster images and vector images?

Ans: There are two types of images that are commonly found in HTML. Raster Images can be described by how the pixels are arranged in a grid. Also, the exact color of the pixel is defined. Popular raster file formats are PNG(.png), JPEG(.jpg), etc.

Vector Images can be described with the usage of algorithms. This includes the shape and path definitions that can be utilized to exhibit the image on-screen written in an almost identical markup manner. Svg. is the file extension that you will observe when working with vector images.

Q9: How can you create a hyperlink in HTML?

Ans: The HTML gives you an anchor tag to help you generate a hyperlink. This will help you move from one page to the other. These tags are distinguished by different colors. They are given differently to see which link is visited by the user, not clicked by the user and if the link is active or not. You may view a link the ways written down below:

  • Unvisited link - It is displayed with an underline and it is blue in color.
  • Visited link - It is displayed with an underline as well. However, the color is purple.
  • Active link - Just like the two previous types, it has an underline. This link is red.