Introduction to Web Technologies and Architectures · Web Technology

Markup Languages and Their Grammars

Watch lectures

Markup Languages and their Grammars

1. What is a Markup Language?

A markup language embeds annotations (tags/markers) into a text document; these annotations are not printed but tell a processor (browser, parser, formatter) how to structure, style or interpret the content.

 <author>       <-- start tag (markup)
  Jane Austen   <-- character data (content)
 </author>      <-- end tag

Two broad kinds of markup:

Kind Purpose Examples
Procedural / presentational How to display (fonts, margins) troff, RTF, old HTML <font>
Descriptive / structural What the content is (semantic) SGML, XML, HTML (ideally), RDF

2. The Family Tree of Markup Languages

                 SGML (1986, ISO 8879)  -- the meta-language (standard)
                 /                \
        HTML (1991)             XML (1998)
        web pages               extensible data
        /      \                    /    |      \
   XHTML    HTML5            XHTML  RSS  MathML  SVG ... WSDL, RDF
                                 |
                    derived vocabularies (custom DTDs / Schemas)
Language Role Key idea
SGML Mother standard; define markup systems Complex, very general
HTML Fixed vocabulary for web pages Pre-defined tags, forgiving parsing
XML Meta-language to invent your own tags Strict syntax, self-describing data
CSS Style sheet (not markup per se) attached to markup Separation of presentation
XSL / XSLT Transform & format XML XML → HTML/text/XML

3. Grammars of Markup Languages

A grammar formally defines which tags are legal, in what order, with which attributes. Markup grammars are described by:

Grammar artefact Used by Specifies
DTD (Document Type Definition) SGML, XML Elements, attributes, entities, hierarchy, occurrence indicators
XML Schema (XSD) XML Same + data types, namespaces, cardinality ranges
RELAX NG / Schematron XML Alternative schema languages (patterns, rules)
Tag sets / profiles HTML Which tags & attributes a browser must support (HTML5 spec)

Grammar goals: validity (does the document follow the grammar?) vs well-formedness (is the syntax correct at all?).

Rules for a well-formed XML/SGML instance: single root element, properly nested tags, every start tag closed, attributes quoted, case-sensitive names, escaped < & > in text.

Valid = well-formed and conforms to its DTD/Schema.

4. Structural Terminology

 Document --> elements (root, parents, children, siblings, leaf)
          --> attributes (name="value")
          --> entities (&lt; &amp; ...)
          --> comments (<!-- ... -->), processing instructions (<?xml ...?>)

A document is a tree; parsers (DOM — tree model, SAX — event stream) walk this tree.

5. Exam Points

  • What is a markup language? Distinguish descriptive vs procedural markup — 5 marks.
  • Draw the family tree of markup languages (SGML → HTML/XML → vocabularies) — 7 marks.
  • Explain the concept of a grammar for markup languages and define well-formed vs valid documents — 7 marks.
  • Compare HTML and XML — 5 marks.
Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Web Technology modules