Question library

HTML interview questions and answers

45 HTML interview questions with answers: 10 junior, 15 mid-level and 20 senior. Junior answers are free to read.

Junior Mid Senior Updated How these answers are created

* View counts were reset on 18 October 2026, when Interviewplus moved to interviewplus.app. Votes were not affected.

Answer

As a language used to create web pages, HTML (Hypertext Markup Language) uses a set of building blocks to structure the content of a document. Here are the basic building blocks of an HTML document and their purpose:

1. HTML tags: HTML tags are the fundamental building blocks of any HTML document. They are used to define the structure and content of a web page. HTML tags are surrounded by angle brackets (<>) and are used to create HTML elements.
2. Head section: The head section of an HTML document contains metadata that provides information about the document, such as the title, keywords, and description. This section is not visible on the web page itself but is used by search engines and other tools to understand the content of the page.
3. Body section: The body section of an HTML document contains the content that will be displayed on the web page. This can include text, images, videos, links, and other elements.
4. Title tag: The title tag is used to define the title of the HTML document. This title is displayed in the browser's title bar and is also used by search engines to help understand the content of the page.
5. Headings: Headings are used to define the main headings of a web page. They are usually displayed in a larger font than the body text and are used to organize the content of the page into sections.
6. Paragraphs: Paragraphs are used to define blocks of text in an HTML document. They are separated by blank lines and are used to create a readable and organized layout for the content.
7. Lists: Lists are used to create ordered or unordered lists of items. They can be used to organize content into bullet points or numbered lists.
8. Links: Links are used to create clickable links to other pages, documents, or resources. They are created using the <a> tag and can be used to navigate between different pages on a website or to link to external resources.
9. Images: Images are used to add visual content to an HTML document. They are created using the <img> tag and can be used to display photos, graphics, or other types of images.
Overall, these basic building blocks of an HTML document provide the structure, content, and functionality needed to create a fully functional and visually appealing web page.

Answer

To create a hyperlink in HTML, you can use the anchor tag <a> and specify the destination URL using the href attribute. Here is an example:

<a href="https://www.example.com">Link Text</a>

In the example above, "Link Text" will be displayed as a clickable link, and when the user clicks on it, they will be taken to the URL specified in the href attribute.
In addition to the href attribute, there are several other attributes that can be used to customize the behavior of a hyperlink in HTML:
1. target: Specifies where to open the destination URL. Possible values include "_self" (open in the same window), "_blank" (open in a new window), "_parent" (open in the parent frame), or "_top" (open in the top-level browsing context).

<a href="https://www.example.com" target="_blank">Link Text</a>

2. title: Specifies additional information about the hyperlink, such as a tooltip. When the user hovers over the link, the title attribute value will be displayed as a tooltip.

<a href="https://www.example.com" title="Visit Example Website">Link Text</a>

3. rel: Specifies the relationship between the current document and the destination URL. This is used for search engine optimization and to prevent search engine penalties for linking to low-quality or spammy websites. Possible values include "nofollow" (tells search engines not to follow the link), "noopener" (prevents the linked page from manipulating the parent page), and "noreferrer" (hides the referrer information).

<a href="https://www.example.com" rel="nofollow">Link Text</a>

By using these attributes, you can create hyperlinks that behave in a way that is tailored to your specific needs and preferences.

Answer

Sure, here's an example HTML page that includes a header, footer, and navigation menu using semantic elements:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Website</title>
</head>
<body>
  <header>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
  </header>
  
  <main>
    <h1>Welcome to my website</h1>
    <p>This is the homepage of my website.</p>
  </main>
  
  <footer>
    <p>&copy; 2023 My Website. All rights reserved.</p>
  </footer>
</body>
</html>

In this example, the <header> element includes a <nav> element with a list of links to different pages on the website. The main content of the page is wrapped in a <main> element, and the footer is enclosed in a <footer> element. Using semantic elements like these helps improve the accessibility and structure of the page for both humans and machines.

Answer

To add an image to an HTML document, you can use the <img> tag, which stands for "image". Here is an example of how to use the <img> tag to add an image to an HTML document:

<img src="image.jpg" alt="Image description">

In the example above, the src attribute specifies the URL of the image file, and the alt attribute provides alternative text for the image. Alternative text is important for accessibility purposes because it is displayed when the image cannot be loaded, and it is also read by screen readers for visually impaired users.
There are several attributes that can be used to control the size and position of the image:
1. width and height: These attributes specify the width and height of the image in pixels. For example, to set the width of an image to 300 pixels, you can use the following code:

<img src="image.jpg" alt="Image description" width="300">

2. style: This attribute allows you to apply CSS styles to the image, which can be used to control its size, position, and other properties. For example, to set the width and height of an image to 300 pixels and center it horizontally, you can use the following code:

<img src="image.jpg" alt="Image description" style="width: 300px; height: 300px; margin: 0 auto;">

In the example above, the margin: 0 auto; rule centers the image horizontally by setting the left and right margins to auto.
3. class and id: These attributes can be used to apply CSS styles to the image using external CSS files or inline styles. By using class and id attributes, you can target specific images and apply custom styles to them.

<img src="image.jpg" alt="Image description" class="my-image">

In the example above, the class="my-image" attribute specifies that the image should be styled using the "my-image" class in an external CSS file.
By using these attributes, you can customize the size and position of images in your HTML documents to create a more visually appealing and engaging web page.

Answer

To create an unordered list in HTML, you can use the <ul> tag, which stands for "unordered list". Here is an example of how to use the <ul> tag to create a simple unordered list:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

In the example above, the <ul> tag creates an unordered list, and each list item is represented by the <li> tag.
There are several attributes that can be used to customize the appearance of the list items:
1. type: This attribute is used to specify the type of bullet used for each list item. The default value is "disc", but you can also use "circle", "square", or "none". For example:

<ul type="circle">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

2. start: This attribute is used to specify the starting number of a numbered list. For example:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

3. class and id: These attributes can be used to apply CSS styles to the list items using external CSS files or inline styles. By using class and id attributes, you can target specific list items and apply custom styles to them. For example:

<ul>
  <li class="list-item">Item 1</li>
  <li class="list-item">Item 2</li>
  <li class="list-item">Item 3</li>
</ul>

In the example above, the class="list-item" attribute specifies that each list item should be styled using the "list-item" class in an external CSS file.
By using these attributes, you can customize the appearance of your unordered lists in HTML to create a more visually appealing and engaging web page.

Answer

The HTML <form> element is used to create a form on a web page that allows users to input and submit data to a server. The purpose of the <form> element is to collect information from the user and send it to a server for processing, such as saving it to a database or sending an email.
To collect user data, the <form> element typically includes one or more input fields, which allow users to enter information such as text, numbers, dates, and checkboxes. Here are some examples of input fields:
1. Text input: Allows users to enter text, such as their name or email address.

<label for="name">Name:</label>
<input type="text" id="name" name="name">

2. Radio buttons: Allows users to select one option from a list of choices.

<label>Gender:</label>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label>

3. Checkbox: Allows users to select one or more options from a list of choices.

<label>Interests:</label>
<input type="checkbox" id="music" name="interests[]" value="music">
<label for="music">Music</label>
<input type="checkbox" id="sports" name="interests[]" value="sports">
<label for="sports">Sports</label>
<input type="checkbox" id="travel" name="interests[]" value="travel">
<label for="travel">Travel</label>

4. Submit button: Allows users to submit the form data to the server.

<input type="submit" value="Submit">

When a user submits a form, the data is sent to the server in the form of an HTTP request, which can be processed by a server-side script, such as PHP or Python. The server-side script can then access the form data and perform various actions, such as saving it to a database or sending an email.
Overall, the HTML <form> element and input fields provide a powerful way to collect user data and interact with a server, allowing web developers to create dynamic and interactive web pages.

Answer

HTML tables are used to organize data in rows and columns on a web page. To create a table in HTML, you can use the <table> element, which serves as the container for the entire table. Here's an example of how to create a basic table with three columns and three rows:

<table>
  <tr>
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
  </tr>
  <tr>
    <td>Row 1, Column 1</td>
    <td>Row 1, Column 2</td>
    <td>Row 1, Column 3</td>
  </tr>
  <tr>
    <td>Row 2, Column 1</td>
    <td>Row 2, Column 2</td>
    <td>Row 2, Column 3</td>
  </tr>
</table>

In the example above, the <table> element creates the table container, and the <tr> element defines each row in the table. Within each row, the <td> element defines each cell in the row.
To customize the appearance of the table, you can use various attributes on the <table>, <tr>, and <td> elements. Here are some common attributes used to style tables in HTML:
1. border: Sets the width of the border around the table.

<table border="1">

2. cellpadding: Sets the padding inside each cell in the table.

<table cellpadding="5">

3. cellspacing: Sets the space between each cell in the table.

<table cellspacing="10">

4. bgcolor: Sets the background color of a cell or row in the table.

<td bgcolor="#FFFFFF">White Cell</td>
<tr bgcolor="#FF0000"><td>Red Row</td></tr>

5. colspan and rowspan: Allows a cell to span multiple rows or columns in the table.

<td colspan="2">This cell spans two columns</td>
<td rowspan="3">This cell spans three rows</td>

By using these attributes, you can customize the appearance and layout of your HTML tables to suit your needs.

Answer

Here's an example of an HTML form that includes various input types:

<!DOCTYPE html>
<html>
<head>
	<title>Example Form</title>
</head>
<body>
	<h1>Example Form</h1>
	<form>
		<label for="name">Name:</label>
		<input type="text" id="name" name="name" required>

		<label for="email">Email:</label>
		<input type="email" id="email" name="email" required>

		<label for="phone">Phone:</label>
		<input type="tel" id="phone" name="phone">

		<label for="message">Message:</label>
		<textarea id="message" name="message"></textarea>

		<label for="newsletter">Subscribe to our newsletter:</label>
		<input type="checkbox" id="newsletter" name="newsletter" value="yes">

		<label for="gender">Gender:</label>
		<input type="radio" id="male" name="gender" value="male">
		<label for="male">Male</label>
		<input type="radio" id="female" name="gender" value="female">
		<label for="female">Female</label>

		<label for="country">Country:</label>
		<select id="country" name="country">
			<option value="USA">USA</option>
			<option value="Canada">Canada</option>
			<option value="Mexico">Mexico</option>
		</select>

		<button type="submit">Submit</button>
	</form>
</body>
</html>

This form includes several different input types:
1. A required text field for the user's name.

2. A required email field for the user's email address.
3. An optional phone number field.

4. A textarea for the user's message.

5. A checkbox for subscribing to a newsletter.

6. Radio buttons for the user's gender.

7. A select menu for the user's country.
The form also includes a submit button for submitting the form data to a server.

Answer

HTML tags and entities are both used to structure and display content in an HTML document, but they serve different purposes.
HTML tags are used to define the structure and layout of a web page, and are enclosed in angle brackets, like <tag>. Tags typically come in pairs, with an opening tag and a closing tag, and the content to be affected is placed between them. For example, the <h1> tag is used to define a top-level heading, and the <p> tag is used to define a paragraph of text.
HTML entities, on the other hand, are used to represent special characters and symbols that may not be directly typable on a keyboard, such as the copyright symbol or an em dash. Entities are represented by a specific code, which is preceded by an ampersand and followed by a semicolon. For example, &copy; represents the copyright symbol, and &mdash; represents an em dash.
Here's an example of how entities can be used in HTML:

<p>This document is &copy; 2023 by Jane Doe.</p>

In the example above, the &copy; entity is used to represent the copyright symbol, which is displayed in place of the entity code.
Entities can be especially useful when working with non-Latin scripts, such as Chinese or Arabic, where keyboard input may not be readily available or accessible. By using entity codes to represent special characters, you can ensure that your content is correctly displayed regardless of the user's device or input method.

Answer

CSS, or Cascading Style Sheets, is used to control the visual presentation of HTML content. Here are the basic steps for using CSS to style HTML elements:
1. Create a separate CSS file or add a style block to your HTML document to define your CSS rules.
2. Use a selector to target the HTML element you want to style. Selectors can be based on element type, class, ID, or other attributes.
3. Specify one or more CSS properties to change the appearance of the selected element(s). Properties include things like font size, color, background, padding, margin, and border.
Here are some basic CSS properties that can be used to change the appearance of text and other content:
1. color: Sets the text color.
2. font-size: Sets the size of the font.
3. font-family: Sets the font family or typeface.
4. font-weight: Sets the font weight, such as bold or normal.
5. text-align: Sets the horizontal alignment of the text.
6. line-height: Sets the spacing between lines of text.
7. background-color: Sets the background color of an element.
8. padding: Sets the space between the content and the edge of an element.
9. margin: Sets the space between elements.
Here's an example of how CSS can be used to style an HTML element:

<h1 class="title">Welcome to my website</h1>

<style>
  .title {
    color: blue;
    font-size: 36px;
    text-align: center;
    margin-top: 50px;
  }
</style>

In the example above, the h1 element with class title is targeted by the CSS rules. The color, font-size, text-align, and margin-top properties are all used to change the appearance of the text, making it blue, increasing the font size to 36 pixels, centering the text, and adding 50 pixels of margin to the top of the element.
By using CSS to style your HTML content, you can create visually appealing and well-organized web pages that are easy to read and navigate.

Answer preview

To create an ordered list in HTML, you can use the `<ol>` element, and enclose each list item in an `<li>` element. Here is an example: This code will create a numbered list, with each item numbered sequentially. You can use several attributes to customize the appearance of the list items, including: 1. `type`: This…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<meta>` tag provides metadata about an HTML document, which is data that describes other data. Metadata can be used to provide information about the document to search engines, web browsers, and other applications. The `<meta>` tag is typically placed within the `<head>` section of an HTML document. Here is…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure, here's an example of how to use the HTML5 <audio> and <video> tags to embed media files within a web page: In this example, we have an <audio> tag and a <video> tag, both with the controls attribute to display the built-in playback controls. Each media file is specified using a <source> tag with the src…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<iframe>` tag is used to embed content from another website or source into an HTML document. The term "iframe" stands for "inline frame," and it allows you to display external web content within a specific area of your web page. The `<iframe>` tag requires a `src` attribute, which specifies the URL of the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML tables can be used to create responsive layouts by adjusting their width and height properties based on the device screen size. Here's an example of how to create a basic HTML table: In this example, the `<table>` element creates the table container, while `<tr>` elements create table rows. The `<th>` element is…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<audio>` and `<video>` tags are used to embed multimedia content, such as audio and video, into an HTML document. The `<audio>` tag is used for audio content, while the `<video>` tag is used for video content. To use the `<audio>` tag, you need to specify the source of the audio file using the `src`…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML forms provide a way to collect user input and submit it to a server for processing. To create a form in HTML, you can use the `<form>` element with various attributes that control its behavior. Here's an example of a basic form: In this example, the `action` attribute specifies the URL where the form data will be…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure! Here's an example of an HTML page that uses DataTables plugin to implement sorting and filtering functionality for a table: This example uses the DataTables plugin to create a table with sorting, filtering, paging, and searching functionality. The plugin is loaded from a CDN, and the table data is hardcoded in…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 semantic elements such as <main>, <header>, and <footer> are designed to provide meaning to the content of a web page, making it more accessible to users and search engines.  - The <main> element is used to indicate the primary content of a web page, typically the section that is unique to that page. - The…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML <nav> tag is a semantic element that is used to define a block of navigation links, typically used to create menus on a website. The purpose of the <nav> tag is to provide semantic meaning to the content, making it easier for search engines and screen readers to understand the purpose of the navigation links…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML5 <canvas> element provides a way to dynamically render graphics, animations, and other visual content on a web page. To use the <canvas> element, you need to first create a canvas element with a unique ID: Once the canvas element has been created, you can use JavaScript to manipulate its contents. The…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML data attributes allow you to store custom data within an HTML element. These attributes begin with "data-" followed by a name that you choose. For example, you could create a data attribute called "color" for a div element: To access the value of a data attribute using JavaScript, you can use the `dataset`…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<meter>` and `<progress>` tags are used to display visual indicators of progress or completion. The `<meter>` tag is used to represent a scalar measurement within a known range. It can be used to indicate values such as disk usage, completion percentage, or any other value that can be measured within a…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure! Here's an example of an HTML page that includes a responsive image gallery using CSS3 flexbox: In this example, we use the display: flex property on the .gallery container to create a flexible layout that will automatically adjust to different screen sizes. We also set the max-width property of the images to 400…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<blockquote>` tag is used to indicate a section of quoted text from another source in an HTML document. This tag is typically used to display a quote that is longer than a single sentence or phrase. The `<blockquote>` tag is a semantic element that helps to indicate the purpose and meaning of the content it…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML microdata and the Schema.org vocabulary are used to provide structured data about a webpage to search engines and other applications. This structured data helps these applications understand the content on a webpage and display it in a more useful way to users. To use HTML microdata and the Schema.org vocabulary…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure! Here's an example of how to use HTML5 canvas to create a simple interactive animation using JavaScript: This code creates a canvas element with a width and height of 400 pixels, and sets up a 2D rendering context. It then defines some variables for the position and velocity of a ball, and uses a drawBall…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 web storage APIs like `localStorage` and `sessionStorage` provide a way to store data on the client side, which can be useful for creating web applications that need to remember user preferences or store data for offline use. Here are the basic steps to use `localStorage` and `sessionStorage`: 1. To set a value…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure, here's an example HTML page that uses Bootstrap to implement a responsive design:

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 WebSockets provide a way for a web application to establish a persistent, bidirectional communication channel with a server. This enables real-time communication between a client and server without the need for continuous polling or frequent HTTP requests. To use WebSockets in an HTML document, the first step is…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<template>` element is used to define a section of reusable HTML content that can be used throughout a document. The `<template>` element is not displayed on the web page, but instead acts as a blueprint for creating new HTML elements. The content within the `<template>` element can include any other HTML…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 provides several features that allow web applications to work offline, even when the user is not connected to the internet. Two of these features are the AppCache and Service Workers APIs. 1. AppCache: The AppCache API allows web developers to specify which files should be cached by the browser so that they can…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

To develop an HTML page that uses the Google Maps API to display a map with markers, infowindows, and other customizations, follow the steps below: 1. Create a new HTML file and add the necessary script tags for the Google Maps API: 2. Replace YOUR_API_KEY with your actual Google Maps API key. If you don't have one…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 drag and drop events can be used to create more complex interactive elements beyond simple drag and drop functionality. For example, sortable lists and multi-file upload widgets can be implemented using drag and drop events. To create a sortable list, you can use HTML5 drag and drop events to capture the drag…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<meter>` and `<progress>` tags are used to display visual indicators of progress or completion of a task.  The `<meter>` tag represents a scalar measurement within a known range, and it can be used to display a gauge or meter that shows the progress of a task. The `value` attribute specifies the current…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 multimedia APIs like WebRTC and getUserMedia can be used to create real-time video and audio communication between clients in web applications. These APIs allow for peer-to-peer communication without the need for plugins or additional software. WebRTC (Web Real-Time Communication) is a free and open-source…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<time>` element is used to represent a specific date and/or time in a standardized machine-readable format. It is designed to make it easier for search engines and other applications to understand and process date and time information on a webpage.  The `<time>` element can be used to display dates, times…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

To use HTML5 geolocation APIs, you can use the `navigator.geolocation` object in JavaScript to obtain the user's current location. Here are the basic steps: 1. Check if the `navigator.geolocation` object is available in the user's browser. 2. If geolocation is available, use the `getCurrentPosition()` method to get…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML5 `<datalist>` element is used to provide a list of predefined options for an input element, which can be used to provide autocomplete suggestions for the user as they type. It works by linking the input element to the `<datalist>` element using the `list` attribute. The `<datalist>` element contains one or…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure, here's an example of how to create a simple hover effect using CSS3 transform and transition properties: This code creates a gray box with a centered text that will scale up by 20% when hovered. The transition property is set to smoothly animate the scaling over 0.3 seconds with an ease-in-out timing function…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<slot>` element is a part of the Web Components API and is used to create a placeholder within a custom HTML component where the content can be dynamically inserted.  The purpose of the `<slot>` element is to allow developers to create reusable, encapsulated components that can be easily modified and…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 Server-Sent Events (SSE) allow a web page to receive updates from a server in real-time, in a unidirectional way. SSE is a lightweight alternative to WebSockets, and is useful when the server needs to push data to the client, without the client needing to request it repeatedly. To use SSE, you need to do the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

The HTML `<dialog>` element is used to create a modal dialog box that can be used to interact with users or display alerts. The `<dialog>` element is part of the HTML5 specification, and it is designed to be a flexible and extensible way to create custom dialog boxes that can be styled and manipulated using CSS and…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

HTML5 WebRTC data channels allow peer-to-peer communication of arbitrary data between two clients connected over the internet. Unlike traditional client-server communication, data channels allow for direct communication between clients without the need for a server intermediary. To use WebRTC data channels, you need…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure, here's an example of using HTML5 drag and drop functionality to implement a file uploader: In this example, we create a div element with the class drop-zone that serves as the target for drag and drop events. We also add an input element with the type attribute set to file, which allows the user to browse for…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

More practice

Go further with HTML

HTML code challenges

10 challenges with answers

Behavioral Questions

10 questions with answers

Cultural Fit Questions

10 questions with answers

Competency-Based Questions

10 questions with answers

Motivational Questions

10 questions with answers

Communication Skills Questions

10 questions with answers

Scenario-Based Questions

10 questions with answers

Problem-Solving and Analytical Questions

10 questions with answers

Ethical and Integrity Questions

10 questions with answers

Industry-Specific Questions

10 questions with answers

Leadership and Management Questions

10 questions with answers

Personal Questions

10 questions with answers

About this topic

HTML interview questions and answers

This page lists 45 HTML interview questions with answers, ordered from junior to senior level. Commonly asked questions include "What are the basic building blocks of an HTML document, and what is the purpose of each one?", "How do you create a hyperlink in HTML, and what attributes can be used to customize its behavior?" and "Create an HTML page that includes a header, footer, and navigation menu, using semantic elements such as <header>, <footer>, and <nav>.".

Other frequently asked questions include "How do you create an unordered list in HTML, and what attributes can be used to customize the appearance of the list items?", "What is the purpose of the HTML form element, and how are input fields used to collect user data?" and "How do you create an ordered list in HTML, and what attributes can be used to customize the appearance of the list items?". Review each answer and consider how you would adapt it to your own experience.

Practise HTML in a mock interview

Answer questions one at a time and receive a score with written feedback on each answer.

Start a mock interview

Reviews and comments