Interview questions

HTML Interview Questions

16 HTML interview questions on semantics, forms, accessibility and script loading, with model answers for front-end candidates and interviewers.

HTML Interview Questions

What's here

16 HTML interview questions, grouped into 4 areas: structure and semantics, forms, accessibility and loading and performance. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Ask candidates to mark up a small design (a card or form) and review the elements they chose
  • Probe accessibility with a keyboard-only scenario rather than definitions
  • Follow the async versus defer answer with 'which would you use for this script?'
For hiring teams

Cohesyve finds, contacts and tests HTML candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

HTML interview questions are often the opening round for front-end developer, web designer and full-stack interviews. They look simple, but they reveal whether a candidate writes accessible, semantic markup that works for every user, search engines and assistive technology included. These questions cover structure and semantics, forms, accessibility, and how markup affects loading. Candidates can use the 'what to look for' notes as model answers; interviewers can use them as a scoring guide.

Structure and Semantics

The building blocks and why choosing the right element matters.

  1. 1

    What does the doctype declaration do?

    Why ask it

    A basic question that checks whether the candidate understands browser rendering modes.

    What to look for

    <!DOCTYPE html> tells the browser to render the page in standards mode rather than quirks mode, which emulates old browser behaviour. It must be the first line of the document. Strong candidates mention the lang attribute on html and the meta charset as other essentials.
  2. 2

    What is semantic HTML, and why does it matter?

    Why ask it

    Semantics affect accessibility, SEO and maintainability.

    What to look for

    Using elements for their meaning: header, nav, main, article, section, aside, footer, button, and headings in order. Semantic elements give assistive technology and search engines structure for free and make code easier to read. A div with a click handler instead of a button loses keyboard support and its role.
  3. 3

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

    Why ask it

    Fundamental layout knowledge.

    What to look for

    Block elements (div, p, h1) start on a new line and take the full available width; inline elements (span, a, strong) sit within a line and take only the width they need. CSS display can change this. Good candidates mention inline-block and that layout today is usually handled with flexbox and grid.
  4. 4

    When would you use article versus section versus div?

    Why ask it

    A precise semantics question that shows depth.

    What to look for

    article for self-contained content that makes sense on its own (a blog post, a comment); section for a thematic grouping, usually with a heading; div when no semantic meaning applies, for example a styling wrapper.
  5. 5

    What are data attributes, and when would you use them?

    Why ask it

    Common in real code and in testing.

    What to look for

    Custom attributes prefixed with data- (data-user-id) that store extra information on elements, readable in JavaScript through dataset and usable in CSS selectors. Good uses: configuration for scripts and stable hooks for automated tests. They should not hold sensitive data.
For hiring teams

Before the HTML interviews, see who can do the work

Cohesyve finds and contacts HTML candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

Forms

Forms are where markup quality most directly affects users.

  1. 6

    How do you make a form field accessible?

    Why ask it

    Unlabelled fields are among the most common accessibility failures.

    What to look for

    A label element linked to the input with for and id (or wrapping it), the correct input type, helpful autocomplete values, grouping related controls with fieldset and legend, and error messages linked to the field so screen readers announce them. Placeholder text is not a substitute for a label.
  2. 7

    What built-in validation does HTML offer, and is it enough?

    Why ask it

    Tests understanding of client versus server responsibilities.

    What to look for

    Attributes such as required, type (email, url, number), min, max, minlength, maxlength and pattern give native validation and suitable mobile keyboards. Client-side validation helps users but can be bypassed, so the server must always validate too.
  3. 8

    What is the difference between GET and POST in a form's method attribute?

    Why ask it

    Connects HTML to HTTP basics.

    What to look for

    GET sends form data in the URL query string, suits searches and filters, and can be bookmarked; it should not change data or carry sensitive values. POST sends data in the request body and suits actions that create or change data.
  4. 9

    Why should buttons inside a form declare a type?

    Why ask it

    A subtle bug that catches many developers.

    What to look for

    A button inside a form defaults to type='submit', so a button meant to open a menu or add a row may submit the form. Declaring type='button' prevents this.

Accessibility

Accessible markup is now a baseline expectation for front-end roles.

  1. 10

    When should you use ARIA attributes?

    Why ask it

    Misused ARIA can make a page worse for screen reader users.

    What to look for

    Prefer native HTML elements that already have the right semantics and behaviour; this is the first rule of ARIA. Use ARIA when no native element fits, for example for live regions or complex widgets, and then you must also provide the keyboard behaviour in script. 'No ARIA is better than bad ARIA' is a good principle to quote.
  2. 11

    How do you write good alt text for images?

    Why ask it

    Shows practical accessibility judgement.

    What to look for

    Describe the purpose or content of the image in context, concisely; use an empty alt (alt='') for purely decorative images so screen readers skip them; for images of text, include the text. Avoid 'image of'.
  3. 12

    Why does heading order matter?

    Why ask it

    Screen reader users often navigate by headings.

    What to look for

    Headings create the document outline; one h1 for the page topic and h2 to h6 in order without skipping levels for styling. Visual size should come from CSS, not from picking a heading level.
  4. 13

    How would you test a page's accessibility?

    Why ask it

    Separates awareness from practice.

    What to look for

    Automated checks (browser dev tools audits, axe-style tools) plus manual tests: keyboard-only navigation with visible focus, a screen reader pass, zoom and colour contrast checks. Automated tools catch only part of the problems.

Loading and Performance

How markup choices affect speed and rendering.

  1. 14

    What is the difference between async and defer on a script tag?

    Why ask it

    Script loading affects how fast a page renders.

    What to look for

    Both download the script in parallel with parsing. async runs the script as soon as it downloads, in no guaranteed order, which suits independent scripts such as analytics. defer runs scripts after the document is parsed, before DOMContentLoaded, in document order, which suits scripts that need the DOM or each other. Module scripts (type='module') are deferred by default. A script with neither attribute blocks parsing.
  2. 15

    How can HTML help images load efficiently?

    Why ask it

    Images are often the heaviest part of a page.

    What to look for

    loading='lazy' for below-the-fold images, width and height attributes to reserve space and avoid layout shift, srcset and sizes or the picture element for responsive images and modern formats, and not lazy-loading the main hero image.
  3. 16

    What belongs in the head of an HTML document?

    Why ask it

    Checks completeness of knowledge about document setup and SEO basics.

    What to look for

    meta charset, the viewport meta tag for responsive layouts, the title, meta description, links to stylesheets, canonical and other link tags, and scripts with defer. Good candidates mention Open Graph tags for sharing and that the title and description affect search results.

Running the interview well

  • 1Ask candidates to mark up a small design (a card or form) and review the elements they chose
  • 2Probe accessibility with a keyboard-only scenario rather than definitions
  • 3Follow the async versus defer answer with 'which would you use for this script?'
  • 4Check whether they reach for a button or a div for clickable elements
  • 5Pair HTML questions with a short CSS or JavaScript task for front-end roles
  • 6Give credit for knowing where to check details, such as MDN

Common questions

What HTML questions are asked in interviews?

Common questions cover the doctype, semantic elements, block versus inline elements, forms and validation, accessibility (labels, alt text, ARIA), async versus defer for scripts, data attributes and what belongs in the head.

Are HTML interview questions only for freshers?

Basic HTML questions are common in junior interviews, but senior front-end interviews also test semantics, accessibility and performance in more depth, often through a practical markup task.

What is the difference between HTML and HTML5?

HTML5 was the name for the version that introduced semantic elements such as header, nav and article, native audio and video, new input types and the canvas element. HTML is now maintained as a living standard, so interviewers mostly just say HTML.

How do I prepare for an HTML interview?

Build a few small pages using semantic elements and accessible forms, test them with only a keyboard, and read the MDN pages for the elements you use. Be ready to explain why you chose each element.

Do HTML interviews include CSS and JavaScript?

Usually. Front-end interviews often start with HTML, then move to CSS layout and JavaScript. Prepare all three, with HTML semantics and accessibility as the foundation.

For hiring teams

Save these questions for the HTML candidates who can do the work

Cohesyve takes your HTML job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for an HTML interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise an HTML interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role