1. Gyanastra
  2. Web Programming
  3. HTML, CSS, JavaScript, XML, Applets and Servlets
  4. HTML Fundamentals
Free lesson, no account needed 15 min read 22 practice questions after it
Asked in past papers10 times
  • ISRO201720112007
  • UGC NET2020201920182016201420132012

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) to h6 (least). A well-formed document uses one h1 as the page title and nests the others in order; skipping levels is legal but poor practice.
  • Lists: <ul> unordered (bullets), <ol> ordered (numbered, attributes type, start, reversed), <dl> description list with <dt>/<dd>; every item of ul/ol is an <li>. Lists nest by putting a whole <ul>/<ol> inside an <li>.
  • Hyperlink element <a>: attribute href = 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 carries href, the destination anchor carries name (HTML 4) or id (HTML5).
    A link to another page's section is written href="page2.html#sec2".
  • Image: <img src="…" alt="…" width height> — void element; alt gives alternative text and is required for accessibility.
    Images are embedded with the img element; 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="…">. The map/area pair defines clickable regions inside one image; area is 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 CSS vertical-align).
    • align (left|center|right) — horizontal alignment (deprecated, replaced by CSS text-align). A CSS rule such as text-align:center; vertical-align:middle affects 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 controls input, textarea, select/option, button, label, fieldset/legend.
    • name is the key sent to the server; a control without name is not submitted.
    • Radio buttons with the same name form one mutually exclusive group (selecting one deselects the others). Checkboxes with the same name are independent; each checked box sends its value.
    • label with for="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 — &amp; &lt; &gt; &quot; &nbsp; &copy;; numeric — &#38; (decimal), &#x26; (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 CSS display property.
  • 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> (and white-space: pre in CSS) preserves whitespace and line breaks.
  • id must be unique in a document; class may repeat on many elements and may hold several space-separated names.

How it works

  1. 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) and body (rendered content).
    Anything visible must be inside body; only metadata inside head.
  2. 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.
  3. Linking — the two-anchor procedure.
    1. Mark the destination: <h2 id="sec2"> or <a name="sec2"></a>.
    2. 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.
    3. The browser loads the target document, then scrolls to the element whose name/id equals the fragment sec2. Without href the a element is not a link; without a matching name/id the fragment does nothing.
  4. 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.
    1. Number columns left to right from 1, rows top to bottom from 1.
    2. For each cell in a row, place it in the first free column of that row and mark rowspan × colspan grid slots as occupied.
    3. A row that runs out of cells before reaching the last used column simply has empty slots there.
    4. The number of columns of the table is the largest column index used.
  5. Form submission. On submit the browser collects every named, non-disabled control: text inputs send their value, checked boxes/radios send their value (unchecked ones send nothing), a select sends the chosen option value, a textarea sends its text.
    With GET the pairs are appended to the action URL after ?; with POST they go into the request body.
  6. Rendering text. The engine applies the whitespace collapsing rule, then CSS display decides block vs inline behaviour and alignment.
    Deprecated presentational attributes (align, valign, bgcolor, frame) still parse but are overridden or replaced by CSS.
Figure. Notice the html element branches into head and body; head holds title, meta, link, and style, while body holds text, headings, lists, links, images, tables, and forms.
Figure. It traces fragment navigation: the link requests page2.html, the parser locates the element with id or name sec2, and the viewport scrolls to that element.

Formulas

  • Grid width in columns: C=max⁡all cells(start column+colspan−1)C=\max_{\text{all cells}}(\text{start column}+\text{colspan}-1), with columns numbered from 1. If no cell spans rows, C=max⁡r(number of cells in row r)C=\max_r(\text{number of cells in row } r).
  • Slots claimed by one cell: rowspan×colspan\text{rowspan}\times\text{colspan}. For a complete table, ∑cells(rowspan×colspan)=R×C\sum_{\text{cells}}(\text{rowspan}\times\text{colspan})=R\times C; a smaller sum means some slots are unfilled (gaps).
  • Height of a table in rows: R=max⁡all cells(start row+rowspan−1)R=\max_{\text{all cells}}(\text{start row}+\text{rowspan}-1).

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.

  1. row 1 uses columns 1–2. Step 2: rows 2 and 3 use columns 1–3. Largest column index = 3, so C=3C=3; R=3R=3. 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 1Col 2Col 3
Row 1Dept (rowspan 2)Scores (colspan 2)← covered by Scores
Row 2← covered by DeptMidEnd
Row 3A12

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: &amp; renders an ampersand character. → True; &amp; is the named reference for &, needed because a bare & starts a reference.
II: &lt;b&gt; is displayed as the literal text <b>, not as bold markup. → True, because &lt; and &gt; 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

Featureidclass
UniquenessMust be unique in the documentMay repeat freely
Main useFragment target, label association, scriptingGrouping elements for styling
Number per elementOneSeveral, space-separated
Featurerowspancolspan
DirectionExtends downward over rowsExtends rightward over columns
Slots claimedrowspan × colspansame
Written ontd or thtd or th
FeatureGETPOST
Data locationAppended to URL after ?Request body
Visibility / lengthVisible, limited lengthHidden, practically unlimited
Suitable forRetrieval, bookmarkable queriesSensitive data, file upload, state change
FeatureBlock-levelInline
Line behaviourStarts a new line, full widthFlows inside a line of text
Examplesdiv, p, h1–h6, ul, table, form, prespan, a, img, em, strong, code, var, cite, samp, input, label
Nesting ruleMay contain block and inlineMust not contain block-level elements
FeatureVoid elementNormal element
Content / end tagNone / noneContent plus end tag
Examplesbr, hr, img, input, meta, link, area, colp, div, table, a, ul, form
TermPrecise meaning
HTML vs programming languageHTML marks structure; it has no variables, loops or conditions
name vs idname is the submitted key and the radio group key; id is a unique document identifier and anchor target
&lt; vs <&lt; prints a literal <; a bare < begins a tag

Revision summary

  1. HTML is a markup language; it is not a programming language, does not specify logic, and is not screen-precise.
  2. SGML = Standard Generalized Markup Language, ISO 8879;
    HTML 4.01 was an SGML application, XHTML an XML application.
  3. Source anchor → href; destination anchor → name (or id). Link syntax: page.html#label.
  4. colspan = horizontal span, rowspan = vertical span; each cell claims rowspan × colspan grid slots.
  5. valign (vertical) and align (horizontal) are deprecated for cells; CSS vertical-align and text-align replace them.
  6. Same name ⇒ one exclusive radio group; checkboxes stay independent; unchecked controls send nothing.
  7. Void elements: area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr.
  8. Character references: &amp; &lt; &gt; &quot; &nbsp; &copy;, numeric &#38; / &#x26;.
  9. cite = reference to a source, em = emphasis/italic, var = program argument, samp = program output.
  10. map + area build clickable regions in one image; area is void.
  11. Whitespace collapses in normal text and is preserved only in pre.
  12. id unique, class repeatable; meta is void and lives in head.

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>; caption first inside table.
  • 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 — name vs id for anchors, align/valign vs CSS. When a question says HTML5, prefer CSS answers; when it says HTML 4, name is 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:

  1. State the full forms and standard numbers: HTML, SGML, ISO 8879, and explain why HTML is not a programming language.
  2. Write a two-anchor link to a section of another page and name the attribute used on each anchor.
  3. List at least ten void elements and say why they have no end tag.
  4. Given a table with mixed rowspan/colspan, draw its grid table and report rows, columns, header cells and data cells.
  5. Solve a numeric question such as "3 rows, one colspan-2 cell, others 3 cells" and justify the column count.
  6. Group radio buttons correctly using name, contrast with checkboxes, and say which values are submitted when nothing is checked.
  7. Distinguish GET from POST on data location, visibility, length and appropriate use.
  8. Expand or decode named and numeric character references and predict exactly what text the browser displays for a mixed snippet.
  9. Match cite, em, var, samp, code, kbd, strong with their semantic purposes.
  10. Place DOCTYPE, html, head, body, title and caption in correct document order, and explain whitespace collapsing versus pre.

Attempt the sub-topic test first, then the subject test.

Pages 1–2 of 2