DEV Community

Cover image for HTML QUESTIONS
ihsaan muhammed
ihsaan muhammed

Posted on

HTML QUESTIONS

1. What is HTML?

Answer:
HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages using elements called tags.


2. What is the latest version of HTML?

Answer:
The latest version is HTML5, which introduced semantic elements, multimedia support, local storage, canvas, and improved APIs.


3. What is the difference between HTML and HTML5?

Answer:

  • HTML5 supports audio and video without plugins.
  • HTML5 introduced semantic tags like <header>, <section>, and <footer>.
  • HTML5 supports local storage.
  • HTML5 includes Canvas and SVG for graphics.

4. What are HTML tags?

Answer:
HTML tags are keywords enclosed in angle brackets (<>) that define the structure and content of a webpage.

Example:

<p>Hello World</p>
Enter fullscreen mode Exit fullscreen mode

5. What are HTML elements?

Answer:
An HTML element consists of the opening tag, content, and closing tag.

Example:

<h1>Welcome</h1>
Enter fullscreen mode Exit fullscreen mode

6. What are attributes in HTML?

Answer:
Attributes provide additional information about HTML elements.

Example:

<img src="image.jpg" alt="Nature">
Enter fullscreen mode Exit fullscreen mode

7. What are semantic HTML elements?

Answer:
Semantic elements clearly describe their purpose.

Examples:

  • <header>
  • <nav>
  • <section>
  • <article>
  • <footer>
  • <main>

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

Answer:

<div> <span>
Block-level element Inline element
Starts on a new line Does not start on a new line
Used for larger sections Used for small text portions

9. What are block-level elements?

Answer:
They occupy the full width available and start on a new line.

Examples:

  • <div>
  • <p>
  • <h1>
  • <section>

10. What are inline elements?

Answer:
Inline elements only occupy the required width.

Examples:

  • <span>
  • <a>
  • <strong>
  • <img>

11. What is the purpose of the DOCTYPE declaration?

Answer:
It tells the browser which version of HTML is being used.

Example:

<!DOCTYPE html>
Enter fullscreen mode Exit fullscreen mode

12. What is the difference between id and class?

Answer:

id class
Unique Can be reused
Used once Used multiple times
Selected using # Selected using .

13. What are lists in HTML?

Answer:

Three types:

  • Ordered List (<ol>)
  • Unordered List (<ul>)
  • Description List (<dl>)

14. How do you create a hyperlink?

Answer:

<a href="https://example.com">Visit</a>
Enter fullscreen mode Exit fullscreen mode

15. How do you insert an image?

Answer:

<img src="photo.jpg" alt="Photo">
Enter fullscreen mode Exit fullscreen mode

16. What is the difference between <b> and <strong>?

Answer:

  • <b> makes text bold.
  • <strong> makes text bold and indicates important content semantically.

17. What is the difference between <i> and <em>?

Answer:

  • <i> displays italic text.
  • <em> displays emphasized text and carries semantic meaning.

18. What are HTML forms?

Answer:
Forms collect user input.

Example:

<form>
<input type="text">
</form>
Enter fullscreen mode Exit fullscreen mode

19. What are some common input types?

Answer:

  • text
  • password
  • email
  • number
  • date
  • checkbox
  • radio
  • file
  • submit

20. What is the difference between GET and POST?

Answer:

GET POST
Data in URL Data in request body
Less secure More secure
Limited data Large data
Used for fetching Used for submitting

21. What is the purpose of the alt attribute?

Answer:
The alt attribute provides alternative text if an image cannot be displayed and improves accessibility.

Example:

<img src="flower.jpg" alt="Red Flower">
Enter fullscreen mode Exit fullscreen mode

22. What is the <iframe> tag?

Answer:
The <iframe> tag embeds another webpage within the current webpage.

Example:

<iframe src="page.html"></iframe>
Enter fullscreen mode Exit fullscreen mode

23. What are HTML comments?

Answer:
Comments are ignored by browsers and used for documentation.

Example:

<!-- This is a comment -->
Enter fullscreen mode Exit fullscreen mode

24. What are the new multimedia elements in HTML5?

Answer:

  • <audio>
  • <video>
  • <source>
  • <track>

These allow multimedia without external plugins.


25. Why is HTML important in web development?

Answer:
HTML provides the structure of every web page. It works with CSS for styling and JavaScript for interactivity, forming the foundation of modern web development.

Top comments (0)