0% found this document useful (0 votes)
23 views

HTML Interview Questions

Uploaded by

munikumarsvec143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

HTML Interview Questions

Uploaded by

munikumarsvec143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Sure!

Here is a list of the top 100 HTML interview questions along with their answers:

### Basic HTML Questions

1. **What is HTML?**

- HTML stands for HyperText Markup Language. It is the standard language for creating web pages and
web applications.

2. **What are tags in HTML?**

- Tags are the basic building blocks of HTML, used to create elements on a web page. Tags are written
in angle brackets, such as `<html>`, `<head>`, `<body>`, etc.

3. **What is the difference between HTML and XHTML?**

- HTML is a standard markup language, while XHTML is a stricter version of HTML that follows XML
rules.

4. **What are attributes in HTML?**

- Attributes provide additional information about HTML elements. They are always included in the
opening tag and usually come in name/value pairs like `name="value"`.

5. **What is a doctype in HTML?**

- A doctype declaration defines the HTML version to the browser. For example, `<!DOCTYPE html>` for
HTML5.

6. **What are the new features in HTML5?**

- HTML5 introduces new elements like `<article>`, `<section>`, `<nav>`, `<header>`, `<footer>`,
`<canvas>`, `<audio>`, `<video>`, etc., along with new attributes and APIs.
7. **What is the purpose of the `<head>` section in HTML?**

- The `<head>` section contains meta-information about the HTML document, such as its title, links to
CSS, scripts, and meta tags.

8. **What is the difference between block-level and inline elements?**

- Block-level elements start on a new line and take up the full width available (e.g., `<div>`, `<p>`,
`<h1>`), while inline elements do not start on a new line and only take up as much width as necessary
(e.g., `<span>`, `<a>`, `<img>`).

9. **How do you create a hyperlink in HTML?**

- Use the `<a>` tag with the `href` attribute. Example: `<a href="https://www.example.com">Click
here</a>`.

10. **How do you insert an image in HTML?**

- Use the `<img>` tag with the `src` attribute. Example: `<img src="image.jpg" alt="Description">`.

### Intermediate HTML Questions

11. **What is the purpose of the `<meta>` tag in HTML?**

- The `<meta>` tag provides metadata about the HTML document, such as character set, author,
description, and viewport settings.

12. **What is the difference between `<div>` and `<span>`?**

- `<div>` is a block-level container, while `<span>` is an inline container.

13. **How do you create a table in HTML?**

- Use the `<table>` tag along with `<tr>` (table row), `<th>` (table header), and `<td>` (table data) tags.
14. **What is the purpose of the `<form>` tag?**

- The `<form>` tag is used to create a form for user input, which can be submitted to a server for
processing.

15. **What are semantic HTML elements?**

- Semantic HTML elements clearly describe their meaning in a human- and machine-readable way.
Examples include `<article>`, `<section>`, `<aside>`, and `<header>`.

16. **How do you embed a video in HTML5?**

- Use the `<video>` tag with the `src` attribute or nested `<source>` tags. Example: `<video
src="video.mp4" controls></video>`.

17. **What is the purpose of the `alt` attribute in images?**

- The `alt` attribute provides alternative text for an image if it cannot be displayed, aiding accessibility
and SEO.

18. **How do you create a list in HTML?**

- Use `<ul>` for an unordered list, `<ol>` for an ordered list, and `<li>` for list items.

19. **How do you specify a character set in HTML?**

- Use the `<meta charset="UTF-8">` tag in the `<head>` section.

20. **What is the use of the `<iframe>` tag?**

- The `<iframe>` tag is used to embed another HTML document within the current document.

### Advanced HTML Questions


21. **What is the difference between `<b>` and `<strong>`, and between `<i>` and `<em>`?**

- `<b>` and `<i>` are used for visual styling (bold and italic), while `<strong>` and `<em>` are used to
give semantic importance (strong emphasis and emphasis).

22. **How do you create a responsive design in HTML?**

- Use the `<meta name="viewport" content="width=device-width, initial-scale=1.0">` tag and CSS


media queries.

23. **What is the purpose of the `data-*` attribute?**

- The `data-*` attribute is used to store custom data private to the page or application.

24. **What is the use of the `<template>` tag in HTML?**

- The `<template>` tag holds client-side content that will not be rendered when the page loads but can
be used later via JavaScript.

25. **How do you implement geolocation in HTML5?**

- Use the Geolocation API, accessed via JavaScript. Example:


`navigator.geolocation.getCurrentPosition(success, error);`.

26. **What are web workers in HTML5?**

- Web workers are scripts that run in the background, separate from the main browser thread,
allowing for background processing.

27. **How do you handle offline web applications in HTML5?**

- Use the `Cache Manifest` to specify resources the browser should cache and make available offline.
28. **What is the purpose of the `<canvas>` element in HTML5?**

- The `<canvas>` element is used to draw graphics on a web page via JavaScript.

29. **How do you include a favicon in a web page?**

- Use the `<link rel="icon" href="favicon.ico" type="image/x-icon">` tag in the `<head>` section.

30. **What is the purpose of the `<picture>` element in HTML5?**

- The `<picture>` element allows you to define multiple sources for an image, providing flexibility for
responsive designs.

### HTML Forms and Input

31. **How do you create a text input field in HTML?**

- Use the `<input type="text">` tag.

32. **What is the use of the `required` attribute in a form input?**

- The `required` attribute specifies that an input field must be filled out before submitting the form.

33. **How do you create a dropdown list in HTML?**

- Use the `<select>` tag with nested `<option>` tags.

34. **How do you create a checkbox in HTML?**

- Use the `<input type="checkbox">` tag.

35. **What is the purpose of the `placeholder` attribute in an input field?**

- The `placeholder` attribute specifies a short hint that describes the expected value of an input field.
36. **How do you create a radio button in HTML?**

- Use the `<input type="radio">` tag.

37. **What is the use of the `<fieldset>` and `<legend>` tags in a form?**

- The `<fieldset>` tag groups related elements in a form, and the `<legend>` tag provides a caption for
the `<fieldset>`.

38. **How do you create a file upload field in HTML?**

- Use the `<input type="file">` tag.

39. **What is the purpose of the `action` attribute in a form?**

- The `action` attribute specifies where to send the form data when the form is submitted.

40. **How do you create a submit button in HTML?**

- Use the `<input type="submit">` tag or the `<button type="submit">` tag.

### HTML5 APIs

41. **What is the Drag and Drop API in HTML5?**

- The Drag and Drop API allows elements to be dragged and dropped within and between web pages.

42. **What is the Web Storage API in HTML5?**

- The Web Storage API provides a way to store data in the browser, including `localStorage` for
persistent storage and `sessionStorage` for temporary storage.
43. **What is the WebSocket API?**

- The WebSocket API provides a way to open a two-way interactive communication session between
the user's browser and a server.

44. **How do you use the History API in HTML5?**

- The History API allows manipulation of the browser's session history, including methods like
`pushState`, `replaceState`, and `popstate` events.

45. **What is the purpose of the `<output>` element?**

- The `<output>` element represents the result of a calculation or user action.

46. **What is the difference between `localStorage` and `sessionStorage`?**

- `localStorage` stores data with no expiration date, while `sessionStorage` stores data only for the
duration of the page session.

47. **What is the purpose of the `<progress>` element?**

- The `<progress>` element represents the completion progress of a task.

48. **How do you use the Geolocation API in HTML5?**

- Use the `navigator.geolocation` object to get the current geographical location of the user.

49. **What is the File API in HTML5?**

- The File API allows

You might also like