HTML (HyperText Markup Language) describes the structure of web pages with elements written as tags. HTML5 adds semantic elements, new form inputs with built-in validation, native audio, video and canvas, and browser storage — the base every other web technology builds on.
High-yield 70 minSyllabus: “HTML”
Mark as
The idea in one minute
Think of HTML as the labels an editor pencils onto a manuscript before it goes to the printer: this is a heading, this is a list, this phrase links to page 7, put a photo here. HTML does not choose fonts or colours — that is CSS's job — it only marks what each piece of content is. The browser reads the labelled manuscript and builds the page; JavaScript can later rearrange it.
Key points — the night-before list
An element = start tag + content + end tag (<p>…</p>). Void elements (br, hr, img, input, meta, link) have no end tag. Attributes sit in the start tag.
Skeleton: <!DOCTYPE html> → html → head (metadata: meta, title, link, script) + body (everything visible).
Block elements (div, p, h1–h6, ul, table) start on a new line and take the full width; inline elements (span, a, img, strong) flow inside a line.
Forms: action = handler URL, method = GET (query string) or POST (body), enctype="multipart/form-data" for uploads. Only controls with a name are submitted.
HTML5 inputs: email, number, date, range, color, url, tel; validation with required, pattern, min/max, maxlength. placeholder is a hint, not a label.
localStorage persists per origin; sessionStorage lasts for one tab; both hold about 5 MB and are never sent to the server — unlike 4 KB cookies.
Obsolete in HTML5: font, center, frame/frameset, big, tt, applet. XHTML = HTML written as strict XML: lowercase, every element closed, attributes quoted.
01What HTML is: elements, tags and attributes
HTML is a markup language, not a programming language: it has no variables or loops. It annotates content with tags that say what each part is — heading, paragraph, link, table, form. Hypertext means text containing links to other text; the links are what turn separate documents into a web.
Tim Berners-Lee — regarded as the father of HTML and the Web — described the first set of HTML tags at CERN in 1991, modelled on SGML (Standard Generalized Markup Language, ISO 8879). Milestones: HTML 2.0 (RFC 1866, 1995), HTML 3.2 (W3C, 1997), HTML 4.01 (1999), XHTML 1.0 (2000), HTML5 (W3C Recommendation, 2014). Since 2019 the single authoritative specification is the HTML Living Standard maintained by WHATWG, the group formed by browser makers.
HTMLAnatomy of an element
<a href="schemes.html" title="All housing schemes">Housing schemes</a><!-- start tag: <a ...> attribute name: href attribute value: "schemes.html"
content: Housing schemes end tag: </a> whole thing: one element -->
Elements must nest properly: <p><strong>…</strong></p> is right; <p><strong>…</p></strong> overlaps and is wrong.
Tag and attribute names are case-insensitive in HTML (lowercase is the convention; XHTML requires it).
Attribute values are best always quoted; HTML tolerates unquoted simple values, XHTML does not.
Void (empty) elements never have content or an end tag: br, hr, img, input, meta, link, area, base, col, embed, source, track, wbr.
Comments are written <!-- like this -->; they are not displayed and cannot be nested.
Runs of spaces and newlines collapse into one space when displayed; use pre or to keep spacing.
Global attribute
Purpose
id
Unique name for one element — CSS #id, JavaScript getElementById, link target #id
class
One or more space-separated class names shared by elements — CSS .class
style
Inline CSS for this element only
title
Advisory text, shown as a tooltip
lang
Language of the content (ml, en-IN) — helps screen readers and search engines
hidden
Element is not rendered
tabindex
Keyboard focus order
data-*
Custom data for scripts, e.g. data-scheme-id="42"
PSC favourite
Father of HTML → Tim Berners-Lee. HTML was defined as an application of SGML (exams say 'HTML is a subset of SGML'). Comment syntax → <!-- … -->. <img> is an empty tag, not a container tag.
02Document structure and metadata
HTMLA complete, valid HTML5 page
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="description" content="Housing schemes of the State Housing Board"><title>Housing schemes</title><link rel="stylesheet" href="style.css"><script src="app.js" defer></script></head><body><h1>Housing schemes</h1><p>Welcome to the <strong>online allotment</strong> portal.</p></body></html>
<!DOCTYPE html> — not a tag but an instruction that puts the browser into standards mode. HTML 4.01 needed a long DTD reference; HTML5 uses this short form.
html — the root element; lang declares the page language.
head — metadata, not displayed: character set, title, descriptions, links to CSS, scripts.
meta charset="UTF-8" — the character encoding; put it first in the head.
title — shown on the browser tab, in bookmarks and as the search-result heading. It is required.
link — attaches external resources, above all style sheets; base sets the base URL for relative links.
Headings run from h1 (most important; normally one per page) to h6; they describe the document's outline, not font sizes. p is a paragraph, br a line break inside one, and hr a thematic break shown as a horizontal rule.
Element
Meaning
Default look
strong / b
Strong importance / stylistic bold with no extra importance
Short inline quotation — the browser adds quote marks
“quoted”
blockquote
Long, block-level quotation
Indented block
abbr
Abbreviation; title gives the expansion
Dotted underline in some browsers
code, kbd, samp, var
Code, keyboard input, sample output, variable
Monospace / italic
pre
Pre-formatted text — keeps spaces and line breaks
Monospace block
Block-level elements
Start on a new line and stretch to the full available width
Can contain other blocks and inline elements
Width, height and margins all apply
div, p, h1–h6, ul, ol, li, table, form, section
Inline elements
Flow within a line of text, only as wide as their content
Should contain only text and other inline elements
Width and height are ignored; vertical margins do not push lines apart
span, a, strong, em, img, input, label, code
div (block) and span (inline) are generic containers with no meaning of their own; they exist to group content for CSS and JavaScript, usually through a class. (An img is inline yet has a width and height — it is a replaced element, behaving like inline-block.)
Any Unicode character by decimal or hexadecimal number
04Links, images and lists
The anchor element a creates a hyperlink; its href attribute holds the destination. target says where to open it: _self (default, same tab), _blank (new tab — add rel="noopener" so the new page cannot control yours), _parent, _top, or the name of a frame.
HTML
<a href="https://www.kerala.gov.in/">Absolute URL: scheme + host + path</a><a href="apply.html">Relative: apply.html in the same folder</a><a href="../forms/apply.html">Relative: up one folder, then into forms/</a><a href="/contact.html">Root-relative: from the top of this site</a><a href="#eligibility">Jump to the element with id="eligibility" on this page</a><a href="mailto:help@kshb.example?subject=Allotment">E-mail link</a><a href="tel:+914712000000">Phone link</a><a href="brochure.pdf" download>Download the brochure</a><a href="https://maps.example/kollam" target="_blank" rel="noopener">Open map in a new tab</a>
Images use the empty element <img src="…" alt="…">. src is the image URL; alt is the text alternative that screen readers speak, that appears when the image fails to load and that search engines index — use alt="" for purely decorative images. Giving width and height lets the browser reserve space before the image arrives; loading="lazy" defers off-screen images. Wrap an image and its caption in figure and figcaption. Image maps (map with area shapes rect, circle, poly) make regions of one picture clickable.
HTMLOrdered (type 1, A, a, I, i; start; reversed), unordered and description lists
<ol type="I" start="3"><!-- numbering III, IV, V --><li>Submit the application</li><li>Document verification
<ul><!-- nested unordered list --><li>Income certificate</li><li>Ration card</li></ul></li><li>Draw of lots</li></ol><dl><!-- description list --><dt>EWS</dt><dd>Economically Weaker Section</dd><dt>LIG</dt><dd>Low Income Group</dd></dl>
PSC favourite
Link URL → the href attribute (not url, link or rel). Insert an image → <img src="…">. External script → <script src="…">. External style sheet → <link rel="stylesheet" href="…">.
05Tables
A table is built row by row: table contains an optional caption, then row groups thead, tbody and tfoot, each holding tr (table row) elements, which hold cells — th for header cells (bold and centred by default; scope="col" or "row" helps screen readers) and td for data cells. colspan="n" stretches a cell across n columns and rowspan="n" down n rows; the positions a span covers are simply left out of the following rows.
HTMLThe second header row and the second body row each have fewer cells because spans above cover the missing positions
<table><caption>Units by scheme</caption><thead><tr><th rowspan="2">District</th><th rowspan="2">Scheme</th><th colspan="2">Units</th></tr><tr><th>Total</th><th>Allotted</th></tr></thead><tbody><tr><td rowspan="2">Kollam</td><td>Sneha Nagar</td><td>120</td><td>96</td></tr><tr><td>Harbour View</td><td>60</td><td>60</td></tr></tbody><tfoot><tr><td colspan="2">Total</td><td>180</td><td>156</td></tr></tfoot></table>
Old attribute
Meaning
HTML5 / CSS replacement
border="1"
Draw cell borders
border: 1px solid on table, th, td
cellpadding
Space between a cell's border and its content
padding on th, td
cellspacing
Space between neighbouring cells
border-spacing, or border-collapse: collapse for none
align, bgcolor, width
Alignment, background, width
text-align, background-color, width
PSC favourite
cellpadding = white space between a cell's edge and its content; cellspacing = space between cells (asked in a 2023 PSC paper). Both are obsolete in HTML5 but still appear in questions.
06Forms and input controls
A form collects input and sends it to the server. action is the URL of the program that receives it (default: the same page). method is get (the default — data appended to the URL as a query string) or post (data in the request body). enctype sets the body format: application/x-www-form-urlencoded (default), multipart/form-data (required for file uploads, together with POST) or text/plain. Each control is submitted as name=value, so a control without a name is never sent.
HTMLA registration form using most control types — try it in the Web playground tool on this page
select with option children makes a drop-down; selected pre-selects, multiple allows several choices, optgroup groups options.
textarea is a multi-line text box; rows/cols set its size and the text between its tags is the initial value.
label with for matching an id ties a caption to its control: clicking the label focuses the control and screen readers read it aloud.
fieldset draws a box around related controls and legend gives that box a caption.
button (types submit, reset, button) can contain markup; datalist offers suggestions for an input.
Validation attribute
Effect
required
Field must not be empty
pattern="[6-9][0-9]{9}"
Value must match the regular expression — the whole value, implicitly anchored
min, max, step
Numeric and date limits
minlength, maxlength
Length limits for text
placeholder
Greyed hint shown while empty — not a substitute for a label
readonly
Cannot be edited but is submitted
disabled
Cannot be edited, greyed out and not submitted
novalidate (on form)
Switch off the browser's built-in checks
Watch out
Browser validation is a convenience, not security: anyone can switch it off or send a request with curl. The server must validate every field again (see the PHP, JSP and ASP.NET topics).
07HTML5: semantics, media, storage and APIs
HTML5 set out to describe content by meaning, to play media without plug-ins such as Flash, to add new form controls and to give scripts powerful browser APIs. Its semantic elements behave like div but tell browsers, search engines and screen readers what each region is:
Element
Represents
header
Introductory content of the page or of a section — logo, title, search
nav
A block of major navigation links
main
The page's main content — only one visible per page
section
A thematic group of content, normally with a heading
article
Self-contained content that makes sense alone: a news item, a post, a notice
aside
Content tangential to the main flow: sidebar, related links
footer
Closing content: copyright, contact, links
figure / figcaption
A picture, diagram or code listing with its caption
details / summary
A disclosure widget the user can open and close
time, mark, dialog
A date or time; highlighted text; a dialog box
HTMLThe browser plays the first source it supports; the inner text appears only in very old browsers
<video controls width="640" poster="project.jpg"><source src="project.webm" type="video/webm"><source src="project.mp4" type="video/mp4"><track kind="subtitles" src="project-ml.vtt" srclang="ml" label="Malayalam">
Your browser does not support the video element.
</video><audio controls loop src="jingle.mp3"></audio>
Media attributes: controls (show play/pause/volume), autoplay (browsers usually allow it only when muted), loop (start again every time it finishes), muted, preload (none, metadata, auto) and, for video, poster (image shown before playback). track adds subtitles or captions in WebVTT format.
canvas
A bitmap drawn by JavaScript: getContext("2d") then fillRect, lineTo, drawImage…
Draw and forget — shapes are pixels, not objects
Fast for games, charts with many points, image editing
Blurs when scaled up
svg
Vector graphics written as XML elements (rect, circle, path, text)
Every shape is a DOM node that CSS and events can target
Ideal for icons, logos, diagrams, maps
Stays sharp at any zoom
JavaScript
// Web Storage: string key/value pairs kept by the browser, per origin
localStorage.setItem("district", "Kollam"); // survives closing the browser
const d = localStorage.getItem("district"); // "Kollam" (null if absent)
sessionStorage.setItem("wizardStep", "2"); // gone when this tab closes
localStorage.setItem("prefs", JSON.stringify({ lang: "ml", font: 18 }));
const prefs = JSON.parse(localStorage.getItem("prefs"));
localStorage.removeItem("district"); // or localStorage.clear()// Geolocation: the browser asks the user's permission (HTTPS pages only)
navigator.geolocation.getCurrentPosition(
(pos) => console.log(pos.coords.latitude, pos.coords.longitude),
(err) => console.log("Location unavailable: " + err.message)
);
Cookie
localStorage
sessionStorage
Capacity
About 4 KB each
About 5 MB per origin
About 5 MB per origin
Lifetime
Until Expires / Max-Age (or browser close)
Until deleted
Until the tab closes
Sent to server
With every matching request
Never
Never
Shared between tabs
Yes
Yes, same origin
No — one tab only
Readable by JavaScript
Yes, unless HttpOnly
Yes
Yes
Other HTML5-era APIs: Web Workers (scripts on background threads), WebSocket (full-duplex connection to the server), Server-Sent Events (EventSource, server-to-browser stream), drag and drop, the History API (pushState for single-page apps), and offline support through Service Workers (the old Application Cache was removed).
08Frames, deprecated tags and HTML vs XHTML
HTML 4 could split the browser window with frameset and frame, each frame loading its own page (noframes held fallback text). Frames broke bookmarking, printing, search indexing and accessibility, so HTML5 removed them. The inline frameiframe survives: it shows another web page inside a rectangle of the current page — maps, videos, payment widgets.
HTMLtitle describes the frame for screen readers; sandbox restricts what the embedded page may do
<iframe src="https://maps.example/embed?q=Kollam" width="600" height="400"
title="Map of the Kollam scheme site" loading="lazy"
sandbox="allow-scripts allow-same-origin"></iframe>
Obsolete element
Use instead
font
CSS font-family, font-size, color
center
CSS text-align: center or margin: auto
big, tt, strike
CSS font-size, a monospace font, del or s
frame, frameset, noframes
iframe or ordinary layouts
applet
object / embed (Java applets are dead)
acronym, basefont, dir
abbr, CSS, ul
marquee, blink
CSS animation (blink was never standard)
Aspect
HTML
XHTML
Basis
HTML's own forgiving syntax (originally SGML)
XML — must be well-formed
Tag names
Case-insensitive
Lowercase only
End tags
Some optional (li, p)
Every element closed
Empty elements
<br>
<br />
Attribute values
Quotes optional for simple values
Always quoted
Minimised attributes
checked, disabled allowed
checked="checked"
Root element
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
Errors
Browser recovers silently
XML parser stops at the first error
MIME type
text/html
application/xhtml+xml
Tip
XHTML rules are just XML's well-formedness rules applied to HTML — learn one list and you know both (see the XML topic).
Worked examples
Try the problem first, then reveal the working one step at a time.
EX 1Counting cells in a table with colspan and rowspan
Build a 4-column camp schedule (columns: Day, 9–11, 11–1, 2–4) with rows Mon, Tue and Wed under a header row. Mon: 'Verification' covers 9–11 and 11–1, 'Draw' at 2–4. Tue: 'Interviews' runs 9–11 on both Tue and Wed; 'Site visit' at 11–1; 'Review' at 2–4. Wed: 'Allotment' covers 11–1 and 2–4. How many th/td cells must each row contain?
EX 2Predicting exactly what a GET form sends
A form has action="search.php" method="get" and these controls in order: <input name="q" value="flat kollam">; <input type="password" name="pin" value="1234">; two radios named type with values rental and ownership, ownership checked; an unchecked checkbox name="pwd"; <input name="ref" value="KSHB" disabled>; <select name="d" multiple> with Kollam and Thrissur selected (Kochi not); <input type="hidden" name="page" value="1">; <button name="go" value="search">. The user clicks the button. What URL is requested?
EX 3Choosing semantic elements for a page layout
A notice page has: a top banner with logo and site title; a row of menu links; the main area with three independent notices (each with its own heading and date); a sidebar of related links; a photo of a housing project with a caption; and a bottom strip with copyright and contact. Which HTML5 elements fit?
EX 4Repairing markup and converting it to XHTML
Correct this fragment and rewrite it as valid XHTML: <P>Apply <B>before <I>31 March</B></I>, then <IMG SRC=logo.png>, <INPUT TYPE=checkbox CHECKED> and <BR>.
Practice session
Work each problem on paper first, then check. Marking one solved earns 10 XP.0/5 solved
Q1
Write HTML for an ordered list numbered with lowercase Roman numerals that starts at iii and has three items; the second item contains a nested bulleted list of two items.
Q2
The current page is https://portal.kshb.example/schemes/kollam/list.html. Resolve each link to an absolute URL: (a) details.html (b) ../thrissur/list.html (c) /contact.html (d) //cdn.example.com/logo.png (e) #apply (f) ?page=2
Write a grievance form that posts to grievance.php with: name (required, at least 3 characters), mobile (10 digits starting 6–9), a category drop-down with three choices, a message box (required, at most 500 characters), a PDF attachment, and a submit button. Which method and enctype must it use, and why?
Q5
Choose cookie, localStorage or sessionStorage for each need and write one line of code (or a header) for it: (a) remember the last district a visitor chose, across visits; (b) remember which step of a 4-step wizard the user is on, only in this tab; (c) the login session id that the server must receive with every request.
Exam traps
b/i are purely presentational; strong/em carry meaning (importance, emphasis). Both pairs look the same by default.
placeholder is not a label — it disappears when typing starts. Use label for=….
disabled fields are not submitted; readonly fields are. Unchecked checkboxes and radios are not submitted at all.
q is for a short inline quotation; blockquote for a long block quotation.
cellpadding (cell edge ↔ content) and cellspacing (cell ↔ cell) are often swapped in options; both are obsolete in HTML5.
Exams say 'HTML is a subset of SGML'. Strictly, HTML up to 4.01 was an application of SGML; HTML5 has its own parsing rules.
Quiz — KPSC style
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
HTML & HTML5 · Question 1 of 12✓ 0 · ✗ 0
Who is regarded as the father of HTML and the World Wide Web?
Past-paper questions on this topic
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.
Past papers · Question 1 of 22✓ 0 · ✗ 0
Modelled on QP 050/2026 · Deputy Manager (IT) / Assistant Programmer / Computer Programmer etc (20 May 2026), Q.68 (reworded)original paper (PDF)