Editor's note: The original version of this post was damaged on the old website — its code examples and later questions were lost. It has been restored and updated for modern HTML5.
HyperText Markup Language (HTML) is the standard markup language for creating web pages. If you're preparing for a web development role, here are common HTML interview questions.
HTML is written as elements made of tags in angle brackets, like <p>. Most tags come in pairs — an opening tag such as <p> and a closing tag such as </p> — while some are empty (void) elements, such as <img> and <br>.
1. What does HTML stand for?
HyperText Markup Language.
2. What is HTML used for?
HTML is the standard markup language for describing the structure and content of web pages.
3. What is the DOCTYPE?
The <!DOCTYPE html> declaration tells the browser which version of HTML the page uses. In HTML5, it's simply <!DOCTYPE html>.
4. What is a tag in HTML?
A tag is a keyword in angle brackets that tells the browser how to structure content, such as <h1> for a main heading.
5. How do HTML tags work?
Most tags come in pairs. The opening tag starts the element, and the closing tag — written with a slash before the tag name — ends it:
<p>This is a paragraph.</p>
6. What is the basic structure of an HTML document?
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
</head>
<body>
Page content goes here.
</body>
</html>
7. How do you create a hyperlink?
A hyperlink is text or an image that, when clicked, takes you to another page. Use the <a> tag with the href attribute:
<a href="https://www.example.com/html">Visit our HTML tutorial</a>
The href attribute specifies the destination, and the link text is what users see and click.
8. What are attributes in HTML?
Attributes provide additional information about an element. They're always specified in the opening tag as name/value pairs:
<img src="logo.png" alt="Company logo">
9. How do you add comments in HTML?
<!-- This is a comment -->
Comments are ignored by the browser.
10. What does CSS stand for?
Cascading Style Sheets.
11. What are the ways to add CSS to HTML?
- Inline: using the
styleattribute on an element - Internal: using a
<style>element in the<head> - External: linking to a separate .css file with
<link rel="stylesheet" href="styles.css">
12. What is the difference between block-level and inline elements?
Block-level elements (such as <div>, <p>, and <h1>) start on a new line and take up the full available width. Inline elements (such as <span>, <a>, and <strong>) flow within text and take up only as much width as needed.
13. What are semantic HTML elements?
Semantic elements clearly describe their meaning, such as <header>, <nav>, <main>, <article>, <section>, <aside>, and <footer>. They improve accessibility and SEO.
14. How do you add an image?
<img src="photo.jpg" alt="Description of the photo" width="600" height="400">
The alt attribute describes the image for screen readers and displays if the image can't load.
15. How do you create a list?
Use <ul> for unordered (bulleted) lists or <ol> for ordered (numbered) lists, with <li> for each item.
16. How do you create a table?
Use <table> with <tr> for rows, <th> for header cells, and <td> for data cells.
17. What is the difference between the id and class attributes?
An id must be unique on a page and identifies a single element. A class can be applied to many elements to style or select them as a group.
18. How do you create a form?
Use the <form> element with input controls such as <input>, <textarea>, <select>, and <button>. The action attribute sets where data is sent, and method sets how (GET or POST).
19. What are meta tags?
<meta> tags in the <head> provide information about the page, such as the character set (<meta charset="UTF-8">), the description used by search engines, and the viewport settings for mobile devices.
20. What's new in HTML5?
HTML5 introduced semantic elements, native <audio> and <video>, the <canvas> element, new form input types (such as email, date, and range), local storage, and better support for mobile devices.
Need help building or updating your website? I.T. For Less can help — contact us.