Chapter 2. Working with HTML Markup

When building a site, one of the most important tasks that you perform is link creation, but HyperText Markup Language (HTML) offers a heap of features beyond links. HTML documents describe the hypertext and contain much of the content users explore while visiting the Web, connecting them to other resources including presentation style, scripts, images, video, sound, and much more. As you’ll see, a key part of working with HTML is knowing when to let other technologies (and sometimes people) do their work.

HTML has been in constant development since its invention in 1992, and web software (like browsers and web-focused IDEs) have evolved apace. As HTML nears its third decade, clear best practices for markup have emerged both from HTML markup itself and from the technical and business ecosystems that interact with it. Clear HTML syntax lets you build a reliable document tree to hold your content and support additional layers of style and behavior. Chapter 5 is devoted to the features of CSS that interact with the document tree.

HTML Syntax

HTML and its stricter sibling XHTML define a set of rules for marking up documents, as well as rules for how that markup should be structured. HTML parsers (but not XHTML parsers) usually follow a principle referred to as “Postel’s Law,” stated as follows:

Be conservative in what you send, and liberal in what you accept.

Where XHTML requires the creator of the document to write very precise markup, HTML ...

Get HTML & CSS: The Good Parts 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.