HTML Interview
15 essential Q&A
most asked
HTML Basics Interview: 15 Essential Q&A
Quick interview-ready answers on core HTML fundamentals for freshers and early developers.
tags
elements
attributes
semantics
forms
links
Quick Navigation
1What is HTML?easy
Answer: HTML (HyperText Markup Language) is the standard markup language used to structure web page content like headings, paragraphs, links, images, forms, and sections.
2What is the difference between a tag and an element?easy
Answer: A tag is the markup token like
<p> or </p>. An element is the full structure: opening tag, content, and closing tag.3Why do we use
<!DOCTYPE html>?easyAnswer: It tells the browser to render the page in standards mode and identifies the document as HTML5.
4What is the basic HTML page structure?easy
Answer: A typical structure includes
<html>, <head> (metadata), and <body> (visible content).<!DOCTYPE html>
<html lang="en">
<head><title>Page</title></head>
<body>Hello</body>
</html>5Block elements vs inline elements?medium
Answer: Block elements usually start on a new line and take full width (e.g.,
<div>, <p>). Inline elements flow within text (e.g., <span>, <a>).6What are HTML attributes?easy
Answer: Attributes provide extra information about elements, such as
href, src, alt, id, and class.7What is semantic HTML and why is it important?medium
Answer: Semantic HTML uses meaningful tags like
<header>, <nav>, <main>, <section>, and <footer>. It improves readability, accessibility, and SEO.8Different types of lists in HTML?easy
Answer:
<ul> (unordered list), <ol> (ordered list), and <dl> (description list).9How do you open a link in a new tab?easy
Answer: Use
target="_blank" on an anchor tag, and add rel="noopener noreferrer" for security.10Why is the
alt attribute important for images?mediumAnswer: It provides alternative text for screen readers and for cases where images fail to load, improving accessibility and usability.
11What are the core tags in an HTML form?medium
Answer: Common form tags include
<form>, <label>, <input>, <select>, <textarea>, and <button>.12What is the difference between
id and class?easyAnswer:
id should be unique on a page, while class can be reused across multiple elements.13What does meta viewport do?medium
Answer: It controls page scaling on mobile devices, making responsive layouts work correctly.
<meta name="viewport" content="width=device-width, initial-scale=1.0">14Name some key HTML5 features.medium
Answer: Native audio/video, semantic tags, form input types (email/date/range), localStorage/sessionStorage, and canvas support.
15Top HTML best practices for interviews?medium
Answer: Use semantic tags, proper heading order, meaningful alt text, accessible forms, valid markup, and clean indentation.
HTML Basics Interview Cheat Sheet
Core Concepts
- Page structure
- Tags vs elements
- Attributes
Accessibility
- Alt text
- Labels in forms
- Semantic landmarks
Interview Focus
- Clean structure
- Real examples
- Best practices