Introduction to HTML


Introduction to HTML Interview with follow-up questions

1. What is HTML and what is it used for?

HTML (HyperText Markup Language) is the standard markup language used to define the structure and content of web pages. It uses a system of elements represented by tags — such as <p>, </p><h1>, <div>, <a>, and <img> — to describe headings, paragraphs, links, images, forms, and every other piece of content a browser renders.

HTML is not a programming language; it has no logic or control flow. Its job is purely to describe what content is on the page and give it semantic meaning. CSS handles presentation, and JavaScript handles behavior.

Key things interviewers expect you to know:

  • HTML documents are parsed by the browser into a Document Object Model (DOM) — a tree of nodes that JavaScript and CSS then interact with.
  • Elements can be block-level (start on a new line, take full width by default — e.g., <div>, <p>) or inline (flow within text — e.g., <span>, <a>).
  • Semantic HTML (using ,, ,, ,) communicates meaning to browsers, search engines, and assistive technologies. Using <div> for everything is technically valid but loses that meaning.
  • The current living standard is HTML5, maintained by WHATWG. There is no "HTML6" — the spec evolves continuously.

A common follow-up is: "What's the difference between HTML and the DOM?" The HTML source is the text file you write; the DOM is the in-memory object representation the browser builds from it. JavaScript manipulates the DOM, not the raw HTML.

↑ Back to top

Follow-up 1

Can you explain the structure of an HTML document?

An HTML document consists of several elements that define its structure. The basic structure of an HTML document is as follows:




    Title of the Document


    Content of the Document


  • ``: This declaration defines the document type and version of HTML being used.
  • ``: The root element of an HTML document.
  • ``: Contains meta-information about the document, such as the title, stylesheets, and scripts.
  • ``: Defines the title of the document that appears in the browser's title bar or tab.
  • ``: Contains the visible content of the document, such as text, images, links, and other elements.

Follow-up 2

What are some common HTML tags and their uses?

HTML tags are used to define the structure and content of an HTML document. Some common HTML tags and their uses include:

  • <h1> to <h6>: Used to define headings of different levels.
  • </h6> </h1><p>: Used to define paragraphs of text.
  • <a>: Used to create hyperlinks to other web pages or resources.
  • <img>: Used to insert images into the document.
  • <ul> and <ol>: Used to create unordered and ordered lists, respectively.
  • <li>: Used to define list items within a list.
  • <div>: Used to group and style elements.
  • <span>: Used to apply styles to a specific section of text.
  • ``: Used to create tables.
  • ``: Used to create input forms for user interaction.
  • ``: Used to create input fields within a form.

Follow-up 3

What is the difference between block-level and inline elements in HTML?

Block-level elements are those that take up the full width available and start on a new line, while inline elements only take up the necessary width and do not start on a new line. Some examples of block-level elements include <div>, <p>, `

` to `

`, and `