Html Top 15 Q/a

Aman SrivastavAman Srivastav
3 min read

Q1: What is HTML ?

HTML stands for HyperText Markup Language.

It is the basic building block of a website โ€” like the skeleton of a web page. ๐Ÿฆด

  • HyperText โ†’ Links that connect web pages.

  • Markup โ†’ Special tags (<tag>) that tell the browser how to display content.

  • Language โ†’ It follows a set of rules to structure the page.

Q2: Difference between HTML and HTML5?

HTML5 adds semantic tags like <header> and <section>, built-in audio/video support, <canvas> for graphics, localStorage/sessionStorage for offline data, and new form input types for better user experience.

Q3: What are semantic tags? Give examples.

A: Tags that describe meaning โ€” <header>, <footer>, <article>, <section>, <nav>.

Q4: Difference between <div> and <span>?

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

Q5: What is DOCTYPE in HTML?

A: Declaration to tell browser which HTML version is used. HTML5 โ†’ <!DOCTYPE html>

Q6: How do you make a required input in HTML5?

A: <input type="text" required>.

Q7: New input types in HTML5?

A: email, date, number, range, color, tel, url.

Q8: Difference between absolute and relative URLs?

A: Absolute includes full path (https://...), relative is based on current page location.

A: <a href="..." target="_blank" rel="noopener noreferrer">.

Q10: How to embed video in HTML5?

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

Q11: Difference between <iframe> and <embed>?

A: <iframe> embeds another HTML page; <embed> embeds external resources (media/PDF).

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

A: Describes the image for accessibility & SEO.

Q13: What is the difference between <script> at head vs before body end?

A: Head blocks rendering; placing before </body> improves performance.

If a <script> is placed in the <head> without async or defer, the browser stops HTML parsing to download and execute it, which can delay page rendering. Placing <script> before </body> lets the browser load the HTML first, making the page appear faster to the user.

Q14: Difference between async and defer in script tags?

A: async loads and executes independently; defer loads in parallel but executes after HTML parsing.

Both async and defer load scripts in the background without blocking HTML parsing. The difference is: async executes the script immediately after it loads (order not guaranteed), while defer executes scripts only after the HTML is fully parsed (order preserved)."


Trick:

async = load & run ASAP, order not guaranteed

defer = load now, run later in order

Q15: Why we use meta tags in HTML?

Meta tags provide metadata about a webpage โ€” information like description, keywords, author, viewport settings, and character encoding. They help search engines understand the content for SEO, control how pages display on devices, and improve accessibility and sharing on social media.

0
Subscribe to my newsletter

Read articles from Aman Srivastav directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aman Srivastav
Aman Srivastav