HTML
HTML fundamentals, semantic elements, forms, media, and accessibility
Questions12 shown
HTML stands for HyperText Markup Language.
Hyper: Refers to the non-linear nature of hypertext, allowing users to jump between documents via links.
Text: The content displayed on web pages — text, images, media.
Markup: The system of tags and attributes that annotate content to define its structure.
Language: A standardized set of rules and syntax for creating web documents.
HTML is the backbone of every web page, defining the structure and semantics of content that browsers render.
HTML is case insensitive. Tags like <DIV>, <div>, and <Div> are all treated the same by browsers. However, best practice is to use lowercase tags for consistency and readability. Note that XHTML, the stricter version, requires lowercase tags.
The <head> tag contains metadata about the HTML document that is not displayed on the page. It includes:
<title> — Sets the browser tab title
<meta> — Charset, viewport, description, keywords
<link> — External stylesheets, favicons
<script> — JavaScript files (with defer/async)
<style> — Internal CSS
<base> — Base URL for relative links
The <head> section is critical for SEO, accessibility, and proper rendering.
Use the <meta> tag with the http-equiv attribute:
<meta http-equiv="refresh" content="60">This tells the browser to automatically refresh the page every 60 seconds. You can also redirect to a different URL:
<meta http-equiv="refresh" content="60;url=https://example.com">Note: This approach is generally discouraged in modern web development. Use JavaScript setInterval() or server-sent events for dynamic updates instead.
<meta http-equiv="refresh" content="60">Block elements take up the full width available and start on a new line:
<div>, <p>, <h1>-<h6>, <section>, <article>, <ul>, <ol>, <form>
Inline elements only take up as much width as necessary and do not start on a new line:
<span>, <a>, <strong>, <em>, <img>, <input>, <label>
Key differences:
Block elements can contain inline elements, but inline elements should not contain block elements.
Block elements respect width/height properties; inline elements do not.
display: inline-block combines features of both.
The <table> tag creates tabular data in HTML.
<table>
<thead>
<tr><th>Name</th><th>Age</th></tr>
</thead>
<tbody>
<tr><td>John</td><td>25</td></tr>
</tbody>
</table>Key elements: <thead>, <tbody>, <tfoot>, <tr> (row), <th> (header cell), <td> (data cell).
Importance: Tables should only be used for tabular data (spreadsheets, schedules, comparisons) — never for page layout. Use CSS Grid or Flexbox for layout instead.
<table>
<thead>
<tr><th>Name</th><th>Age</th></tr>
</thead>
<tbody>
<tr><td>John</td><td>25</td></tr>
</tbody>
</table>HTML provides multiple input mechanisms: 1. **`<input>`** — text, password, email, number, date, checkbox, radio, file, range, color 2. **`<textarea>`** — Multi-line text input 3. **`<select>` + `<op...
Create a free account to unlock login-level content, or go premium for everything.
Use `<input type="file">`: [code block] To accept multiple files: `<input type="file" multiple>` To restrict file types: `<input type="file" accept=".jpg,.png,.pdf">` For a custom styled button: [...
Create a free account to unlock login-level content, or go premium for everything.
Use the `accept` attribute on the file input: [code block] You can also use MIME types: [code block] **Important:** The `accept` attribute only filters the file picker — it does not prevent users f...
Create a free account to unlock login-level content, or go premium for everything.
**`colspan`** makes a cell span multiple columns: [code block] **`rowspan`** makes a cell span multiple rows: [code block] These attributes are used in `<td>` and `<th>` elements to create complex t...
Create a free account to unlock login-level content, or go premium for everything.
**Semantic elements** clearly describe their meaning: - `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`, `<footer>`, `<figure>`, `<figcaption>`, `<time>`, `<mark>` **Non-semantic e...
Create a free account to unlock login-level content, or go premium for everything.
The `<noscript>` tag defines content to be displayed when JavaScript is disabled or not supported in the browser: [code block] **Use cases:** - Showing fallback content for users with JS disabled - ...
Create a free account to unlock login-level content, or go premium for everything.
Interview Preparation
PremiumHigh-signal questions that come up most in real interviews. These are the ones worth spending extra time on.
The `<!DOCTYPE html>` declaration: 1. **Tells the browser** which version of HTML the page uses 2. **Triggers standards mode** — without it, browsers use "quirks mode" which emulates old browser beha...
Create a free account to unlock login-level content, or go premium for everything.
The `<picture>` element provides multiple image sources for responsive design: [code block] **Advantages:** 1. **Art direction** — Different images for different screen sizes 2. **Format fallback** ...
Create a free account to unlock login-level content, or go premium for everything.
The `srcset` attribute lets the browser choose the best image based on device capabilities: [code block] - **`w` descriptor** — Tells the browser the width of each image - **`x` descriptor** — Pixel...
Create a free account to unlock login-level content, or go premium for everything.
**`loading="lazy"`** — Defers loading until the element is near the viewport: [code block] **`loading="eager"`** — Loads immediately (default behavior): [code block] **Best practices:** - Use `lazy`...
Create a free account to unlock login-level content, or go premium for everything.
The `<marquee>` tag creates scrolling text or images: [code block] **Attributes:** `direction`, `scrollamount`, `scrolldelay`, `behavior`, `loop` **Important:** The `<marquee>` tag is **deprecated*...
Create a free account to unlock login-level content, or go premium for everything.
Use the `<link>` tag with `rel="icon"` in the `<head>`: [code block] Modern best practice is to provide multiple formats: - `.ico` for legacy browsers - `.svg` for modern browsers (supports dark mod...
Create a free account to unlock login-level content, or go premium for everything.