Web Programming · HTML, CSS, JavaScript, XML, Applets and Servlets
HTML Fundamentals
Overview
HTML (HyperText Markup Language) is the markup language used to describe the structure of a web document: it labels pieces of content as headings, paragraphs, lists, tables, forms, links and images so that a browser can lay them out.
In the UGC NET syllabus this lesson belongs to Web Programming Core and is the foundation on which CSS, JavaScript, DHTML and server-side topics are built.
A paper-setter expects exact knowledge of the element/attribute inventory, the two-anchor mechanism of hyperlinks, table-spanning rules, form submission rules, character references, and the historical facts (SGML/ISO 8879, "HTML is not a programming language").
No prior knowledge beyond "a browser displays a page from a URL" is assumed; every term is defined below.
Key concepts
- HTML = HyperText Markup Language. A markup language annotates content with tags; it is not a programming language (no variables, no control flow, no computation).
- SGML = Standard Generalized Markup Language, the meta-language for defining markup languages, standardised as ISO 8879. HTML 4.01 was defined as an SGML application (the standard wording: "ISO 8879 — information processing — text and office systems — SGML").
XML is a simplified subset of SGML; HTML5 is not defined with SGML but keeps the same tag vocabulary. XHTML is HTML rewritten under XML rules (well-formed, case-sensitive, all tags closed). - Tag = the markup
<p>…</p>. Element = start tag + content + end tag (the whole thing). Attribute =name="value"written inside the start tag only. - Void (empty) element: has no content and no end tag. Standard list:
area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr. In HTML5 a trailing slash (<br />) is allowed but not required. - Document skeleton, in this order:
<!DOCTYPE html>,<html>,<head>(metadata:title,meta,link,style,script),<body>(visible content). The<!DOCTYPE html>line is not an element; it selects standards mode in the browser. - Headings:
h1(most important) toh6(least). A well-formed document uses oneh1as the page title and nests the others in order; skipping levels is legal but poor practice. - Lists:
<ul>unordered (bullets),<ol>ordered (numbered, attributestype,start,reversed),<dl>description list with<dt>/<dd>; every item oful/olis an<li>. Lists nest by putting a whole<ul>/<ol>inside an<li>. - Hyperlink element
<a>: attributehref= destination URL (absolute, relative, or#fragment);target= where to open (_self,_blank);name/id= makes the element a link destination. Two-anchor rule: the clickable source anchor carrieshref, the destination anchor carriesname(HTML 4) orid(HTML5).
A link to another page's section is writtenhref="page2.html#sec2". - Image:
<img src="…" alt="…" width height>— void element;altgives alternative text and is required for accessibility.
Images are embedded with theimgelement; you cannot show an image from HTML without it (CSS backgrounds and embedded SVG are the only alternatives). - Image map:
<img usemap="#m">+<map name="m">containing<area shape="rect|circle|poly|default" coords="…" href="…" alt="…">. Themap/areapair defines clickable regions inside one image;areais void. - Tables:
<table>,<caption>(title, must come first),<colgroup>/<col>(column grouping/formatting),<thead>,<tbody>,<tfoot>,<tr>,<th>(header cell: bold and centred by default),<td>(data cell: left aligned by default).colspan="n"— the cell spans n columns horizontally.rowspan="n"— the cell spans n rows vertically.valign(top|middle|bottom) — vertical alignment of a cell's content (deprecated in HTML5, replaced by CSSvertical-align).align(left|center|right) — horizontal alignment (deprecated, replaced by CSStext-align). A CSS rule such astext-align:center; vertical-align:middleaffects both directions.frame— an old<table>attribute choosing which outer borders are drawn (void,above,below,hsides,vsides,lhs,rhs,box,border).
- Forms:
<form action="…" method="get|post">with controlsinput,textarea,select/option,button,label,fieldset/legend.nameis the key sent to the server; a control withoutnameis not submitted.- Radio buttons with the same
nameform one mutually exclusive group (selecting one deselects the others). Checkboxes with the samenameare independent; each checked box sends itsvalue. labelwithfor="id-of-control"(or by wrapping the control) activates the control when clicked.- GET appends data to the URL as
?k=v&k2=v2(visible, length-limited, cacheable, should be idempotent). POST sends data in the request body (not in the URL, no practical size limit, for sensitive or state-changing data).
Default method is GET.
meta(void):charset="utf-8",name="description|keywords|viewport" content="…",http-equiv="refresh|content-type".- Character reference (entity): named —
&<>" ©; numeric —&(decimal),&(hex). Entities represent reserved/special characters; they are not a way to include external content.
The four that must always be escaped in text are&,<,>,". - Block-level elements start on a new line and take full available width (
div,p,h1–h6,ul,ol,li,table,form,pre,hr,section,article).
Inline elements flow within text (span,a,img,strong,em,code,var,cite,samp,kbd,label,input,br,sub,sup). In HTML5 the older "block" wording became the CSSdisplayproperty. - Phrase (logical) tags the exam tests:
<cite>— title of a work / reference to another source (italic);<em>— emphasis (italic);<var>— a variable or argument to a program (italic);<samp>— sample output from a program (monospace);<code>— code fragment;<kbd>— keyboard input;<strong>— strong importance (bold);<dfn>— defining instance of a term;<blockquote>— long quotation;<q>— short inline quotation. - Whitespace rule: in normal flow the browser collapses runs of spaces, tabs and newlines into a single space and drops leading/trailing whitespace;
<pre>(andwhite-space: prein CSS) preserves whitespace and line breaks. idmust be unique in a document;classmay repeat on many elements and may hold several space-separated names.
How it works
- Reading the document. The browser fetches the file, sees
<!DOCTYPE html>and switches to standards mode, then builds the tree:html→head(title, meta, styles, scripts) andbody(rendered content).
Anything visible must be insidebody; only metadata insidehead. - Parsing tags. Each start tag creates an element node; matching end tags close it. Void elements close immediately. Attributes are read only from the start tag.
Unclosed or wrongly nested tags are repaired by the parser according to a fixed algorithm, but a well-formed document needs none of that. - Linking — the two-anchor procedure.
- Mark the destination:
<h2 id="sec2">or<a name="sec2"></a>. - Write the source anchor with
href:<a href="#sec2">go</a>for the same page,<a href="page2.html#sec2">go</a>for another page. - The browser loads the target document, then scrolls to the element whose
name/idequals the fragmentsec2. Withouthreftheaelement is not a link; without a matchingname/idthe fragment does nothing.
- Mark the destination:
- Table grid algorithm (for rowspan/colspan). Fill a grid row by row; a spanning cell claims a rectangle of cells and those slots are skipped by later cells.
- Number columns left to right from 1, rows top to bottom from 1.
- For each cell in a row, place it in the first free column of that row and mark
rowspan × colspangrid slots as occupied. - A row that runs out of cells before reaching the last used column simply has empty slots there.
- The number of columns of the table is the largest column index used.
- Form submission. On submit the browser collects every named, non-disabled control: text inputs send their
value, checked boxes/radios send theirvalue(unchecked ones send nothing), aselectsends the chosenoptionvalue, atextareasends its text.
With GET the pairs are appended to the action URL after?; with POST they go into the request body. - Rendering text. The engine applies the whitespace collapsing rule, then CSS
displaydecides block vs inline behaviour and alignment.
Deprecated presentational attributes (align,valign,bgcolor,frame) still parse but are overridden or replaced by CSS.
Drawing the diagram…
Drawing the diagram…
Formulas
- Grid width in columns: , with columns numbered from 1. If no cell spans rows, .
- Slots claimed by one cell: . For a complete table, ; a smaller sum means some slots are unfilled (gaps).
- Height of a table in rows: .
Worked examples
Example 1 — two-anchor linking (direct recall).
"Linking to another place in the same or another webpage requires two a tags; the first has the ___ attribute and the second has the ___ attribute."
The source anchor is the one the user clicks, so it needs the destination URL: href. The destination anchor marks a place in a document, so it needs a label: name (HTML 4 style; today id is the preferred equivalent). Answer: HREF & NAME.
Example 2 — counting columns (numeric, two-step).
A table has 3 rows. Row 1 has one cell with colspan="2". Rows 2 and 3 have 3 ordinary cells each.
- row 1 uses columns 1–2. Step 2: rows 2 and 3 use columns 1–3. Largest column index = 3, so ; . Row 1 leaves column 3 empty (a gap), which is legal HTML. Answer: 3 columns.
Example 3 — tracing a spanning table (hard, code style).
<table border="1">
<tr><th rowspan="2">Dept</th><th colspan="2">Scores</th></tr>
<tr><th>Mid</th><th>End</th></tr>
<tr><td>A</td><td>1</td><td>2</td></tr>
</table>
| Col 1 | Col 2 | Col 3 | |
|---|---|---|---|
| Row 1 | Dept (rowspan 2) | Scores (colspan 2) | ← covered by Scores |
| Row 2 | ← covered by Dept | Mid | End |
| Row 3 | A | 1 | 2 |
Row 1 claims Dept at (1,1)–(2,1) and Scores at (1,2)–(1,3); row 2's first free slot is therefore column 2, so Mid→(2,2), End→(2,3); row 3 fills normally. Result: 3 columns, 3 rows, 4 header cells, 3 data cells; "Dept" appears once but covers two rows.
Example 4 — radio buttons (direct concept).
Three <input type="radio"> controls must behave as one exclusive group (selecting one clears the others). The grouping key is the name attribute: all three must share the same name value.
Different names create independent groups; id must stay unique and therefore cannot group them. Answer: the name attribute must be identical.
Example 5 — statement type on character references.
I: & renders an ampersand character. → True; & is the named reference for &, needed because a bare & starts a reference.
II: <b> is displayed as the literal text <b>, not as bold markup. → True, because < and > are the escaped forms of the angle brackets and the parser never treats them as tags.
III: Character entities are used to embed external content such as images. → False; entities encode characters only. Therefore statements I and II are true and III is false.
Example 6 — match the list (phrase tags).
List-I: cite, em, var, samp. List-II: (i) italic representation, (ii) output from programmes, (iii) reference to another source, (iv) argument to a programme.
Matching: cite → (iii) reference to another source; em → (i) italic representation; var → (iv) argument/variable of a programme; samp → (ii) sample program output.
Comparison
| Feature | id | class |
|---|---|---|
| Uniqueness | Must be unique in the document | May repeat freely |
| Main use | Fragment target, label association, scripting | Grouping elements for styling |
| Number per element | One | Several, space-separated |
| Feature | rowspan | colspan |
|---|---|---|
| Direction | Extends downward over rows | Extends rightward over columns |
| Slots claimed | rowspan × colspan | same |
| Written on | td or th | td or th |
| Feature | GET | POST |
|---|---|---|
| Data location | Appended to URL after ? | Request body |
| Visibility / length | Visible, limited length | Hidden, practically unlimited |
| Suitable for | Retrieval, bookmarkable queries | Sensitive data, file upload, state change |
| Feature | Block-level | Inline |
|---|---|---|
| Line behaviour | Starts a new line, full width | Flows inside a line of text |
| Examples | div, p, h1–h6, ul, table, form, pre | span, a, img, em, strong, code, var, cite, samp, input, label |
| Nesting rule | May contain block and inline | Must not contain block-level elements |
| Feature | Void element | Normal element |
|---|---|---|
| Content / end tag | None / none | Content plus end tag |
| Examples | br, hr, img, input, meta, link, area, col | p, div, table, a, ul, form |
| Term | Precise meaning |
|---|---|
| HTML vs programming language | HTML marks structure; it has no variables, loops or conditions |
name vs id | name is the submitted key and the radio group key; id is a unique document identifier and anchor target |
< vs < | < prints a literal <; a bare < begins a tag |
Revision summary
- HTML is a markup language; it is not a programming language, does not specify logic, and is not screen-precise.
- SGML = Standard Generalized Markup Language, ISO 8879;
HTML 4.01 was an SGML application, XHTML an XML application. - Source anchor →
href; destination anchor →name(orid). Link syntax:page.html#label. colspan= horizontal span,rowspan= vertical span; each cell claimsrowspan × colspangrid slots.valign(vertical) andalign(horizontal) are deprecated for cells; CSSvertical-alignandtext-alignreplace them.- Same
name⇒ one exclusive radio group; checkboxes stay independent; unchecked controls send nothing. - Void elements:
area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr. - Character references:
& < > " ©, numeric&/&. cite= reference to a source,em= emphasis/italic,var= program argument,samp= program output.map+areabuild clickable regions in one image;areais void.- Whitespace collapses in normal text and is preserved only in
pre. idunique,classrepeatable;metais void and lives inhead.
Previous-year exam insights
- Direct attribute recall is the commonest style: which attribute links, which attribute groups radios, which attribute spans a cell, which attribute holds an alternative text.
Learn the exact attribute names, not paraphrases. - Match List-I with List-II on phrase tags (
cite,em,var,samp) or on table parts (thead,caption,tfoot,colgroup) — remember purposes, not just spellings. - Statement I / II (and III) items: one true fact paired with one plausible falsehood, e.g. entities shown as "external content",
id"need not be unique",class"must be unique".
Check each statement independently. - Numeric/grid questions on
rowspan/colspan: count columns as the largest column index used, and remember a short row leaves blank slots instead of widening the table. - Order-of-parts questions:
<!DOCTYPE html>→html→head→body→</html>;captionfirst insidetable. - Trap: HTML described as a programming language or as "screen precise" — both wrong.
It is a markup language for structure and hypertext. - Trap: mixing historical and modern syntax —
namevsidfor anchors,align/valignvs CSS. When a question says HTML5, prefer CSS answers; when it says HTML 4,nameis still valid. - Trap: quoted vs unquoted attribute text in code snippets — read the markup literally, decide which characters are tags and which are escaped text before answering what the browser displays.
Practice at PARIKSHA
You are ready for the PARIKSHA tests of this sub-topic when you can:
- State the full forms and standard numbers: HTML, SGML, ISO 8879, and explain why HTML is not a programming language.
- Write a two-anchor link to a section of another page and name the attribute used on each anchor.
- List at least ten void elements and say why they have no end tag.
- Given a table with mixed
rowspan/colspan, draw its grid table and report rows, columns, header cells and data cells. - Solve a numeric question such as "3 rows, one colspan-2 cell, others 3 cells" and justify the column count.
- Group radio buttons correctly using
name, contrast with checkboxes, and say which values are submitted when nothing is checked. - Distinguish GET from POST on data location, visibility, length and appropriate use.
- Expand or decode named and numeric character references and predict exactly what text the browser displays for a mixed snippet.
- Match
cite,em,var,samp,code,kbd,strongwith their semantic purposes. - Place
DOCTYPE,html,head,body,titleandcaptionin correct document order, and explain whitespace collapsing versuspre.
Attempt the sub-topic test first, then the subject test.