HTML (Hypertext Markup Language) provides the “skeleton” of your website, the underlying
structure and hierarchy for information. Other similar languages like Markdown or RST
do the same thing. In essence, it organizes your pages. CSS, on the other hand styles
these pages.
…refers to the meaning of a piece of code — for example “what effect does running that line of JavaScript have?”,
or “what purpose or role does that HTML element have” (rather than “what does it look like?”.)
Proposed in 1980 by the legend Sir Tim Berners-Lee,
HTML’s current specification started to emerge in 1991 with the creation of a proposal for 18elements,
though it would take until 1993 for a formal specification.
HTML rests on a few principles:
HTML creates documents, which have
limited base interactivity, largely meant to
connect and provide context for information, rendered
in a software referred to as a browser
HTML can:
embed scripting languages such as Javascript
use Cascading Style Sheets (CSS)
include media such as images or video
use interactive forms to provide or change web content
The Markup portion of HTML means that the language uses tags to annotate information,
that is: HTML provides additional information about the information presented. This can include:
content type
content role
information hierarchy
links to content
inclusion of additional page resources, including, but not limited to:
Tags constitute the method of annotation. In all, there exist 142 distinct tags. Many
feature additional properties which provide specific, context-based, information about
the information they annotate. Tags are:
surrounded by < and > symbols
case-insensitive, though convention dictates lower-case usage, e.g. <title> vs. <TITLE>
some are “self-closing,” while others require closing tags around information, e.g.:
Tags create elements. The term element, then, refers to both the information included in the
element and the tag(s) that characterize that information. For example:
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Etiam venenatis libero eget nisl hendrerit,
et elementum nisl cursus.</p>
is refered to as a paragraph element and is rendered:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Etiam venenatis libero eget nisl hendrerit,
et elementum nisl cursus.
Images are examples of “self-closing” tags that create elements (referred to as void elements in
the literature). An example:
<img
src="https://placecats.com/100/100"
width = "100"
height = "100"
alt = "A pair of cute cats"
/>
Rendered as:
In the case of our img element, we notice several different properties:
src
width
height
alt
While the kinds of properties available depend largely on the tag/element itself, here:
Property
Meaning
src
Source for image, typically a URL (relative or absolute)
width
Specified image width, in pixels
height
Specified image height, in pixels
alt
Alternative text to display if image doesn’t load and for accessibility tools like screen readers
As for the tags that create elements, it’s unlikely that a developer will ever use all of them, at least
in a single page. However, the list below provides a concise view of the most common:
Each has a default representation in a browser, as the brower’s job is to render content, even if it’s not
necessarily valid HTML. We override this default view using a stylesheet (CSS), which takes the place of
a given browser’s “root” stylesheet.
Most of the above are notvoid elements, so they require content and closing tags.
The first step to creating a given page is to develop it as a document, using a structure like that below. The
HTML below includes comments to describe the various parts.
<!-- Set the document type to HTML -->
<!Doctypehtml>
<!-- Create the root element -->
<htmllang="en">
<!-- Create page metadata, known as the "head" -->
<head>
<!-- Add metadata like character set, screen size, and page title -->
While we’re not into how we style pages yet, it’s worth knowing that how you organize
the information on your page can affect styling. For example:
<img
src="https://placecats.com/200/200"
width = "200"
height = "200"
alt = "A cat with a banana"
/>
<img
src="https://placecats.com/199/199"
width = "199"
height = "199"
alt = "A cat staring directly at the viewer"
/>
Browsers render content like a program’s flow-of-control: top-to-bottom, left-to-right. Repositioning
these elements in CSS is possible, but potentially changes the meaning of the page, and might
cause some accessibility issues for assistive technologies that don’t render CSS. If the above were two
related steps to a process, it’s possible that the reader has gotten them backwards!
Similarly, designers should arrange content in a hierarchical view on a page. For example:
<h1>A major heading</h1>
A really big point.
<h2>A sub-heading</h2>
A medium point related to the big point.
<h1>A sub-sub heading</h1>
A small point, I want to relate to the medium point.
Look, I just wanted it to be big.
A major heading
A really big point.
A sub-heading
A medium point related to the big point.
A sub-sub heading
A small point, I want to relate to the medium point.
Look, I just wanted it to be big.
The above would cause problems, as the page says that the second <h1> should be at the same level
as a top-level point in the hierarchy. This confuses the information structure.