📚 Top 10 HTML Interview Questions With Answers
1. What is HTML?
HTML (HyperText Markup Language) is the standard language used to create and design web pages. It structures content by using elements and tags.
2. What are the different types of HTML tags?
There are block-level tags (like
3. What is the difference between HTML elements and tags?
A tag is the markup itself (e.g.,
4. What are semantic HTML elements?
Semantic elements clearly describe their meaning in a human- and machine-readable way. Examples include
5. What is the purpose of the
The
6. What are the different ways to include CSS in an HTML page?
CSS can be added via inline styles (
7. What is the difference between an ID and a Class in HTML?
ID is unique within a page and is used to identify a single element, while class can be assigned to multiple elements for styling or scripting.
8. How do you create a hyperlink in HTML?
Using the
9. What are HTML forms used for?
Forms collect user input and submit data to a server for processing, with tags like
10. What is the role of the
Meta tags provide metadata about the HTML document such as character set, page description, viewport settings, and SEO info.
Double Tap ♥️ For More
1. What is HTML?
HTML (HyperText Markup Language) is the standard language used to create and design web pages. It structures content by using elements and tags.
2. What are the different types of HTML tags?
There are block-level tags (like
<div>
, <p>
, <h1>
) which start on a new line, and inline tags (like <span>
, <a>
, <img>
) which do not start on a new line.3. What is the difference between HTML elements and tags?
A tag is the markup itself (e.g.,
<p>
), while an element includes the opening tag, content, and closing tag (<p>Content</p>
).4. What are semantic HTML elements?
Semantic elements clearly describe their meaning in a human- and machine-readable way. Examples include
<header>
, <footer>
, <article>
, and <section>
.5. What is the purpose of the
doctype
declaration in HTML? The
<!DOCTYPE html>
declaration defines the document type and version of HTML, helping browsers render the page correctly.6. What are the different ways to include CSS in an HTML page?
CSS can be added via inline styles (
style
attribute), internal styles (<style>
tag inside <head>
), or external style sheets linked via <link>
tag.7. What is the difference between an ID and a Class in HTML?
ID is unique within a page and is used to identify a single element, while class can be assigned to multiple elements for styling or scripting.
8. How do you create a hyperlink in HTML?
Using the
<a>
tag with an href
attribute, e.g., <a href="https://example.com">Link</a>
.9. What are HTML forms used for?
Forms collect user input and submit data to a server for processing, with tags like
<form>
, <input>
, <textarea>
, <button>
, and more.10. What is the role of the
<meta>
tag in HTML? Meta tags provide metadata about the HTML document such as character set, page description, viewport settings, and SEO info.
Double Tap ♥️ For More
❤10
Web development cheatsheet Part-1 🌐📝
HTML Basics
- Structure:
- Headings:
- Links:
- Images:
- Lists:
- Forms:
CSS Basics
- Inline:
- Internal:
- External:
- Selectors:
- Flexbox/Grid for layout
JavaScript Basics
- Add to HTML:
- Variables:
- Functions:
- DOM:
Best Practices
- Use semantic tags:
- Keep CSS and JS in separate files
- Make sites responsive with media queries
React ❤️ for Part-2
HTML Basics
- Structure:
<html> <head> <title>Title</title> </head> <body> ... </body> </html>
- Headings:
<h1>
to <h6>
- Links:
<a href="url">Text</a>
- Images:
<img src="path.jpg" alt="desc">
- Lists:
<ul><li>Item</li></ul>
(unordered) <ol><li>Item</li></ol>
(ordered)- Forms:
<form> <input type="text"> </form>
CSS Basics
- Inline:
<p style="color:red;">Text</p>
- Internal:
<style> p { color: blue; } </style>
- External:
<link rel="stylesheet" href="style.css">
- Selectors:
.class
, #id
, element
- Flexbox/Grid for layout
JavaScript Basics
- Add to HTML:
<script src="script.js"></script>
- Variables:
let
, const
, var
- Functions:
function myFunc() { ... }
- DOM:
document.getElementById("id")
Best Practices
- Use semantic tags:
<nav>
, <main>
, <footer>
- Keep CSS and JS in separate files
- Make sites responsive with media queries
React ❤️ for Part-2
❤5