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

HTML Questions and Answers

Uploaded by

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

HTML Questions and Answers

Uploaded by

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

HTML Questions and Answers

1. Basic HTML Questions

Q: What does HTML stand for?

A: HTML stands for HyperText Markup Language.

Q: What is the purpose of the <html> tag?

A: It wraps all the content and defines the document as HTML.

Q: What is the structure of a basic HTML document?

A: <!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

</head>

<body>

<h1>Hello, World!</h1>

</body>

</html>

Q: What are HTML tags? Give examples.

A: Tags define HTML elements. Examples: <p>, <h1>, <img>, <a>.

Q: What is the difference between <div> and <span>?

A: <div> is block-level; <span> is inline-level. Both are containers.

2. HTML Elements & Attributes

Q: What is the difference between block-level and inline elements?

A: Block-level take full width (e.g., <div>), inline flow within a line (e.g., <span>).

Q: What is the use of the <a> tag and how do you create a hyperlink?

A: <a href="https://example.com">Visit Example</a>

Q: How can you insert an image in HTML?

A: <img src="image.jpg" alt="Description">

Q: What is the purpose of the alt attribute in the <img> tag?

A: It provides alternate text for the image and improves accessibility.


HTML Questions and Answers

Q: What are global attributes in HTML?

A: Attributes like id, class, style, title that can be used on any element.

3. Forms and Input

Q: How do you create a form in HTML?

A: <form action="/submit" method="post">

<input type="text" name="username">

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

</form>

Q: What are different input types in HTML?

A: text, password, email, number, checkbox, radio, file, submit, reset.

Q: What is the difference between <input type='text'> and <textarea>?

A: <input> is for one line; <textarea> is for multiple lines.

Q: What is the use of the action and method attributes in a form?

A: action defines where to send data; method defines how (GET or POST).

Q: How can you create a dropdown menu?

A: <select name="options">

<option value="1">Option 1</option>

<option value="2">Option 2</option>

</select>

4. Semantic HTML

Q: What is semantic HTML and why is it important?

A: Uses meaningful tags like <article> and <section> for better readability and SEO.

Q: What is the difference between <section>, <article>, and <div>?

A: <section>: grouped content, <article>: self-contained, <div>: generic container.

Q: When should you use <header>, <footer>, and <nav>?

A: <header>: intro, <footer>: end of section, <nav>: navigation links.

5. Tables and Lists


HTML Questions and Answers

Q: How do you create an ordered and unordered list?

A: <ol><li>First</li></ol> <ul><li>Item</li></ul>

Q: What are the basic tags used to create a table?

A: <table>, <tr>, <th>, <td>

Q: How do you merge rows and columns in an HTML table?

A: <td colspan='2'> to merge columns, <td rowspan='2'> to merge rows.

6. Multimedia and Embedding

Q: How do you embed a video or audio file in HTML?

A: <video><source src='video.mp4'></video> <audio><source src='audio.mp3'></audio>

Q: What is the purpose of the <iframe> tag?

A: It embeds another HTML page or external content like a YouTube video.

7. HTML5 Features

Q: What are some new elements introduced in HTML5?

A: <article>, <section>, <nav>, <header>, <footer>, <canvas>, <video>, <audio>

Q: How does the <canvas> element work?

A: It allows drawing graphics via JavaScript.

Q: What is the <video> tag and how is it used?

A: <video controls><source src='movie.mp4' type='video/mp4'></video>

8. Best Practices and Miscellaneous

Q: What are meta tags and how do they help in SEO?

A: <meta name="description" content="..."> gives info for search engines.

Q: How do you make a webpage mobile-friendly using HTML?

A: <meta name="viewport" content="width=device-width, initial-scale=1.0">

Q: How is accessibility handled in HTML?

A: Use alt text, semantic tags, aria attributes, and proper headings.

You might also like