Meaningful Markup

The most significant thing to note here is that the tags describe the information they contain in a meaningful way. In XML, element names are intended to be simple, descriptive, and easily readable by human beings as well as machines. Notice also that the tags do not provide any indication of how the document should look when it is displayed. Their purpose is to provide a semantic description (the meaning) of their contents. XML documents rely on style sheets to handle all matters of presentation.

Together, the elements in a document create its structure. Notice in the example that some elements contain other elements, which may contain yet more elements. This hierarchy is referred to as the document tree . It starts with a root element (compilation in the example) and branches out in layers of parent/child relationships. Every XML document must have exactly one root element, and the root element has no ancestors. Document structure is covered in more detail in Chapter 16.

Tip

The concepts of semantic markup and document structure are directly relevant to web design. HTML and XHTML are markup languages for describing text documents whose “data” consists of paragraphs, headings, lists, and so on. In proper HTML markup, elements should accurately describe their contents, and should not be chosen to achieve a particular visual effect in a browser. Additionally, an awareness of a document’s structure will be a major advantage when planning and writing style sheets. ...

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.