HTML interview questions and answers for a fresher:

HTML interview questions and answers for a fresher:

1. What is HTML?

Answer: HTML is the standard language for creating web pages.

2. What are tags in HTML?

Answer: Tags are used to create HTML elements.

3. What is the difference between HTML and HTML5?

Answer: HTML5 is the latest version with new features like audio, video, and new elements.

4. What is a semantic element in HTML?

Answer: A semantic element clearly describes its meaning (e.g., <article>, <footer>).

5. What is the purpose of the <head> element in HTML?

Answer: The <head> contains meta-information about the document.

6. Explain the difference between block-level and inline elements.

Answer: Block-level elements take up the full width; inline elements take up only as much width as needed.

7. What is the <DOCTYPE> declaration in HTML?

Answer: It defines the version of HTML (e.g., <!DOCTYPE html> for HTML5).

Answer: Use the <a> tag with the href attribute.

9. How can you include an image in a webpage?

Answer: Use the <img> tag with the src attribute.

10. What is the purpose of the alt attribute in an <img> tag?

Answer: It provides alternative text for the image.

11. How do you create a table in HTML?

Answer: Use the <table>, <tr>, <th>, and <td> tags.

12. What is the purpose of the meta tag in HTML?

Answer: It provides metadata about the HTML document.

13. How can you add comments in HTML?

Answer: Use <!-- comment -->.

14. What is the difference between <div> and <span>?

Answer: <div> is block-level; <span> is inline.

15. How do you create a form in HTML?

Answer: Use the <form> tag with input elements like <input> and <button>.