HTML Basics

Learn to write the HTML that gives every web page its structure. Start with elements, attributes and the skeleton of a document, including its language, character encoding and title. Then organize text with headings, paragraphs, emphasis and lists, connect pages with clear links and navigation menus, add images with useful alt text and captions, and divide a page into meaningful regions such as header, main and footer. The unit ends with a complete, valid page that is ready to be styled with CSS.

BeginnerLesson 2 of 8 in Web Development Basics Course

What you will learn

  1. Read and write HTML elements and attributes, set up a complete document with its language, encoding and metadata, and check the markup for errors.
    • Read and write elements, tags and attributes
      Recognize the parts of an element, write attributes correctly, nest elements properly and know how the browser treats spaces and comments.
    • Set up the document skeleton and its head
      Write the doctype, the html, head and body elements, and the metadata every page needs, and save the files with web-friendly names.
    • Declare the language and character encoding
      Use the lang attribute to state the language of a page and of passages within it, and use UTF-8 so that accented letters and other scripts display correctly.
    • Check and fix your markup
      Find and correct HTML errors with a validator and the browser's developer tools, and recognize the mistakes beginners make most often.
  2. Organize text into a clear hierarchy of headings and paragraphs, mark meaning inside sentences, and present items as the right kind of list.
    • Organize text with headings and paragraphs
      Use the six heading levels to build a logical outline, write paragraphs, and use line breaks and thematic breaks only where the content needs them.
    • Mark emphasis, quotations and code inside text
      Choose the text-level element that matches the meaning of a word or phrase: emphasis, importance, quotations, abbreviations, code, dates and more.
    • Build unordered, ordered and description lists
      Choose between unordered, ordered and description lists by meaning, nest lists correctly and control the numbering of ordered lists.
  3. Create links to other sites, to pages in your own site and to places within a page, write link text that makes sense, and build clear navigation menus.
    • Create links with absolute and relative URLs
      Write the anchor element, choose between absolute, relative and root-relative addresses, and link to sections, email addresses and phone numbers.
    • Write clear link text and control how links open
      Write link text that names its destination, link to downloads and images, and decide when a link should open in a new tab.
    • Build navigation menus and in-page links
      Mark up site menus, tables of contents, breadcrumbs and skip links, and keep navigation consistent across the pages of a site.
  4. Place images in a page with the right file, size and format, and give each one a text alternative and, where useful, a caption.
    • Embed images with the img element
      Add images with img, choose a suitable file format, give the width and height, and keep file sizes reasonable.
    • Write alt text and add captions
      Write alt text that fits the purpose of each image, mark decorative images correctly, and use figure and figcaption for captions.
  5. Divide a page into meaningful regions, choose the right element for each block of content, and combine everything into a complete, well-structured page.
    • Mark up the main page regions
      Use header, nav, main, aside and footer to mark the regions of a page and understand how they become landmarks for assistive technology.
    • Choose between article, section, div and span
      Decide whether a block of content is an article, a section or only a styling wrapper, and nest these elements and their headings correctly.
    • Plan and mark up a complete page
      Plan a page's structure before writing code, then combine metadata, headings, text, lists, links, images and page regions into one valid page.

HTML study guide

5 chapters

1

Write well-formed HTML documents

Every page begins with text that the browser turns into a tree of elements. Learn to read that structure, add attributes and build a document with the right metadata. Language and encoding settings help the same page handle different kinds of text. You will also compare your source with the browser’s parsed result and use an HTML checker to find errors that a normal page view can hide.

1.1 Elements, attributes and nesting

HTML labels the parts of a page so the browser can build its structure. A heading, a paragraph and a link have different meanings, even before you add any styling. HTML describes content; CSS controls its appearance, and JavaScript adds behavior.

Read an element

In <p>The workshop opens at noon.</p>, <p> is the start tag, the sentence is the content, and </p> is the end tag. The whole thing is a paragraph element. The slash marks the end tag. Use lowercase element names so your source stays consistent, even though HTML also accepts uppercase names.

An attribute adds information inside a start tag:

<a href="hours.html" title="Workshop opening hours">Opening hours</a>

Here href supplies the destination and title supplies advisory text. Separate attributes with spaces and put their values in straight quotation marks. Their order does not change their meaning. Quotes keep a value together: class="intro note" gives two class names, while class=intro note is read as one class value and a separate attribute named note.

Put elements inside one another

A paragraph can contain a word with strong importance:

<p>Bring your <strong>booking number</strong>.</p>

Open the paragraph, open the strong element, close the strong element, then close the paragraph. Close the most recently opened element first. The paragraph is the parent, and the strong element is its child. Children and everything inside them are descendants. The browser organizes these relationships into the DOM, or Document Object Model, a tree of the page's content.

Not every element can go inside every other element. For example, a list cannot sit inside a paragraph. Indentation helps you see nesting, but adding spaces cannot make an invalid parent-child relationship valid.

Recognize special kinds of elements and attributes

Void elements have no content and no end tag. Examples are <img>, <br>, <hr>, <meta> and <link>. Write <br>, without </br>. A trailing slash in <br /> has no effect in HTML.

A boolean attribute is on when it is present. For an ordered list, reversed makes the numbering count down. Writing reversed="false" still leaves the attribute present, so it still counts down. Remove the attribute to turn it off.

Some attributes work across elements:

AttributeMeaning
idOne unique identifier within the page, with no spaces
classOne or more space-separated names that elements may share
langThe language of the element's content
titleAdvisory text, often shown as a mouse tooltip
hiddenMarks content that is not currently displayed
Read source spacing and comments

In ordinary text, several spaces, tabs or source line breaks collapse to one space. Writing a paragraph over three source lines still gives one paragraph on screen. Use elements to express structure and source indentation to make it readable.

A comment looks like <!-- Menu starts here -->. It is hidden from the displayed page but visible in the source. Never put passwords or private information in comments. Comments cannot be nested: the first --> ends the comment.

Key Takeaways

  • An element includes its tags and content; attributes belong in its start tag.
  • Quote attribute values and close nested elements from the inside out.
  • Void elements have no end tag.
  • A boolean attribute is enabled by its presence, even if its value says "false".
  • Use unique ids and shared class names; ordinary source whitespace collapses.

1.2 The document skeleton and page information

A complete page separates information about the document from the content people read. Start with a small, consistent skeleton, then add the page's own title and body content.

Build the skeleton
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Opening Hours – Harbor Café</title>
  </head>
  <body>
    <h1>Harbor Café</h1>
    <p>Open every day except Monday.</p>
  </body>
</html>

<!DOCTYPE html> tells the browser to use standards mode, its normal modern rendering rules. It is a declaration, not an element. Leaving it out can trigger quirks mode, which imitates older browser behavior and can change layout and sizing.

<html> is the root element. Its two element children are <head> and <body>. The head holds metadata, information about the page. The body holds the visible content. An <h1> belongs in the body, even if the browser appears to recover when you put it in the head.

Give the page its identity

The <title> appears in the browser tab, bookmarks and history. Search engines may also use it for a result headline. Give each normal page exactly one title, inside the head. Put the specific topic first, followed by the site name, such as "Opening Hours – Harbor Café". The visible <h1> and the document title are separate elements with different jobs.

Place <meta charset="utf-8"> first in the head. The entire declaration must be within the file's first 1,024 bytes. An early declaration lets the browser discover how to decode text before it has read much of the page.

The viewport line asks mobile browsers to use the device width for layout and an initial zoom of 1. Without it, many use a wide virtual desktop viewport and shrink the result, making text appear small. This line prepares the document for mobile layout; the page's styling still determines how its content fits.

Connect other page resources

Common additions to the head include:

<meta name="description" content="Fresh bread, coffee and lunch by the harbor.">
<link rel="icon" href="favicon.png">
<link rel="stylesheet" href="styles.css">
<script src="app.js" defer></script>

The description summarizes the page and may appear in search results. The icon supplies the tab image. The stylesheet link connects a CSS file. The script element connects JavaScript; defer delays its execution until the document has been parsed. Unlike <link> and <meta>, <script> needs an end tag even when its content is empty.

Save a web page file

Save plain text in a code editor with an .html extension. A word processor can add formatting that does not belong in an HTML source file. A folder's default page is conventionally index.html; most web servers send it when someone requests the folder address.

Choose lowercase names with hyphens, such as opening-hours.html. Spaces become %20 in URLs, and many servers distinguish uppercase from lowercase. Check that the editor did not save your page as index.html.txt. After saving, open the HTML file in the browser and refresh it when you make a change.

Key Takeaways

  • Put the doctype first, metadata in <head>, and page content in <body>.
  • Use one specific <title> and place the UTF-8 declaration early.
  • Include the viewport meta element for mobile devices.
  • <script> needs an end tag; <meta> and <link> do not.
  • Save plain-text .html files with consistent lowercase names; index.html is the usual folder default.

1.3 Languages, UTF-8 and special characters

The language of text and the way its characters are stored answer different questions. A browser needs both to present the page correctly, especially when the content includes accents or more than one writing system.

Name the language of the content

Write the main language on the root element: <html lang="en">. Screen readers can choose pronunciation from this information, and browsers can use it for translation and spelling. A language tag begins with a language code. An optional second part can name a region or script.

TagContent language
enEnglish
en-USEnglish as used in the United States
en-GBBritish English
fr-CAFrench as used in Canada
zh-HansChinese in simplified characters

The tag describes the content, not the visitor's location. uk means Ukrainian, so it is not the tag for English in the United Kingdom.

Mark a change of language on the nearest suitable element:

<p>Our host said <span lang="fr">bon appétit</span>.</p>

Only the French phrase receives French pronunciation. For a whole quotation, the language can go on its <blockquote>. A right-to-left page also needs its base text direction, for example <html lang="ar" dir="rtl">. Arabic letters still run right to left without that attribute, but the base direction affects paragraph alignment, punctuation and mixed-direction text.

Match the saved bytes and the declaration

A character encoding maps characters to stored bytes. UTF-8 can represent all Unicode characters, including accented letters, other scripts and emoji. HTML documents use UTF-8.

There are two steps: save the actual file as UTF-8 in the editor, and declare <meta charset="utf-8"> early in the head. The declaration tells the browser how to read bytes; it does not convert a file saved in another encoding. A server's encoding declaration in its Content-Type header takes precedence over the meta element.

An encoding mismatch often leaves a clue. UTF-8 text "Café" read as Windows-1252 can become "Café" because the two bytes for "é" are interpreted separately. A Windows-1252 file read as UTF-8 can instead show "Caf�" because the byte is invalid in UTF-8. Check the editor's encoding and the browser's received document information before replacing individual letters.

Display characters that HTML uses as syntax

To show literal tag-like text, write character references:

<p>Use &lt;p&gt; for paragraphs.</p>

The page displays "Use

for paragraphs." The < must be represented as &lt; so the browser does not begin a tag. Each named reference starts with & and ends with ;.

ReferenceDisplayed character or effect
&lt; and &gt;Less-than and greater-than signs
&amp;Ampersand
&quot;Double quotation mark, useful inside a quoted attribute
&nbsp;A space that prevents a line break
&copy;Copyright symbol

For example, 10&nbsp;km keeps the number and unit on the same line. Ordinary accented characters can be typed directly into a UTF-8 file; you do not need a separate reference for every accent.

Key Takeaways

  • lang identifies the content language; dir sets the base text direction.
  • Mark a language change on the element containing that passage.
  • Save the file as UTF-8 and declare UTF-8; a declaration does not convert stored bytes.
  • Use character references when a literal character would be mistaken for HTML syntax.

1.4 Finding and fixing markup errors

A browser tries to display a page even when its HTML is wrong. That helpful recovery can hide errors, so checking a page means examining both the source you wrote and the structure the browser built.

Compare source with the DOM

View Page Source shows the HTML received by the browser. The Elements or Inspector panel in developer tools shows the DOM, the parsed tree the browser is using. The browser may have closed an element early or moved content to another place during parsing.

Open the inspector by right-clicking the page and choosing Inspect, or use your browser's developer-tools shortcut. Select a displayed element and look at its parent and children. Then find the same area in the source. Differences can explain unexpected spacing, links that extend too far or styling applied to the wrong elements.

Trace an automatic repair

Suppose you write:

<p>Our soups:
  <ul>
    <li>Tomato</li>
    <li>Lentil</li>
  </ul>
</p>

A paragraph accepts text-level content, not a list. On reaching <ul>, the browser closes the paragraph. The list becomes a separate block. The final </p> has no open paragraph to close, so parsing can create an extra empty paragraph.

The repair you want belongs in the source:

<p>Our soups:</p>
<ul>
  <li>Tomato</li>
  <li>Lentil</li>
</ul>

Move the paragraph's end tag before the list. The DOM can now express the intended relationship without error recovery.

Use an HTML checker

The W3C Nu Html Checker accepts a page address, a file upload or pasted HTML. It reports errors and warnings with locations. Start with the first error, fix it, and run the checker again. A single missing quotation mark may cause many later messages, so editing every reported line at once can waste effort.

For example, <a href="about.html> lacks the closing quote. The browser can treat following markup as part of the attribute value. Fixing the quote may remove several later errors. Similarly, a missing </a> can make unrelated text join the link.

Look especially for:

  • Elements closed in the wrong order or misspelled names such as <pargraph>.
  • The same id used twice on one page.
  • An <li> outside its list.
  • An image with no alt attribute.
  • Visible content placed in the head.
Check meaning as well as syntax

A clean checker result tells you that the tested markup follows its rules. It cannot decide whether "Click here" is useful link text or whether an image's alt text gives the right information. Read the page in order and check those choices yourself.

Before finishing a page, check the doctype, document language, early UTF-8 declaration and specific title. Review heading levels, unique ids, image alternatives and link destinations. Open the page in at least two browsers and follow its links. A valid relative path can still point to a missing file, which a syntax check alone will not discover.

Key Takeaways

  • Browser recovery can make invalid HTML appear to work.
  • Compare received source with the parsed DOM to find repairs.
  • Fix the first checker error and recheck before chasing later messages.
  • Check content meaning, images and destinations yourself after checking syntax.
2

Structure text with headings, paragraphs and lists

Clear text structure helps people scan a page and understand how its ideas fit together. Headings and paragraphs create the outline; text-level elements add meaning inside it. Lists group items and sequences without relying on visual spacing. Work from the content’s purpose when choosing an element, including when the browser’s default bold text, bullets or line breaks make different choices look similar.

2.1 Headings, paragraphs and breaks

Headings give readers a map of the page. Paragraphs hold related sentences within that map. Choose their elements from the content's structure, then let CSS set their appearance.

Make a heading outline

HTML has six heading levels, <h1> through <h6>. Use one <h1> for the page's main topic, <h2> for its main sections and <h3> for parts within an <h2> section. Most pages need only a few levels.

<h1>Growing Basil at Home</h1>
<p>Basil grows well on a sunny windowsill.</p>
<h2>Planting</h2>
<p>Sow the seeds 0.5 cm deep in moist soil.</p>
<h2>Care</h2>
<h3>Watering</h3>
<p>Water when the top of the soil feels dry.</p>
<h3>Harvesting</h3>
<p>Pick the top leaves first.</p>

Read just the headings. "Planting" and "Care" are equal main sections. "Watering" and "Harvesting" belong under "Care". This outline remains useful when a screen reader lists the headings or when a reader scans the page quickly.

A heading can go down only one level from the previous heading: after <h1>, use <h2>, not <h3>. Going back up can skip several levels. An <h2> after an <h4> starts a new main section. Heading levels follow the whole document, including content inside sections and articles.

The HTML standard permits multiple top-level headings, but one main <h1> is the common, clear pattern. Do not choose <h4> just because its default text is smaller. A bold paragraph may look like a heading, but it will not appear in a screen reader's heading list.

Separate a subtitle from a section

A tagline describes the heading beside it; it does not introduce a new section. Group a heading and subtitle in <hgroup>:

<hgroup>
  <h1>Harbor Café</h1>
  <p>Fresh bread every morning</p>
</hgroup>

The paragraph remains a subtitle. Making it <h2> would incorrectly place it in the page outline as a main section.

Use paragraphs for related sentences

A <p> element holds a paragraph. Start a new paragraph when the subject or step of the explanation changes. Browsers add visible space around paragraphs by default.

Pressing Enter in ordinary HTML source does not create a new displayed paragraph. Likewise, empty <p> elements are not a spacing tool. Keep the structure meaningful and set extra space with CSS.

Choose a break by meaning
ElementUse
<br>A line break that belongs to the text, such as a poem or postal address
<hr>A thematic break, such as a change of scene

For an address, <p>Harbor Café<br>12 Quay Street<br>Port Town</p> keeps the lines together as one paragraph. Repeated <br> elements between ordinary paragraphs confuse content structure with spacing. A horizontal line drawn by <hr> expresses a topic change; choose it because of that meaning, not simply to decorate the page.

Key Takeaways

  • Heading levels express hierarchy; use one main <h1> and descriptive section headings.
  • Do not skip a heading level when moving deeper into the outline.
  • Use <hgroup> with a paragraph for a subtitle.
  • Use <p> for paragraphs, <br> for content line breaks, and <hr> for topic changes.

2.2 Meaning within text

Text elements tell the browser what a word or passage means. Their default bold, italic or indented appearance is only a starting style. Choose the meaning first.

Distinguish stress, importance and attention
ElementMeaningExample
<em>Stress that affects how a sentence is understoodI <em>did</em> lock the door.
<strong>Importance, seriousness or urgency<strong>Warning:</strong>
<i>An alternative voice, technical term or foreign phrase<i lang="la">Homo sapiens</i>
<b>Attention without extra importanceA product name in a review

Moving the emphasis in "I did lock the door" changes what the speaker is correcting. Strong importance does a different job: a warning matters regardless of how the sentence is spoken. Use CSS when you only want a visual style.

Mark quotations and their sources

A long quotation uses <blockquote>. Its optional cite attribute gives a source URL, but that address is not displayed automatically. Put a visible attribution outside the quotation:

<blockquote cite="https://example.com/interview">
  <p>The garden is open to everyone.</p>
</blockquote>
<p>From <cite>A Conversation About the Garden</cite>.</p>

<cite> marks the title of a work, not a person's name. A short quotation inside a sentence uses <q>, and the browser supplies the quotation marks. Do not type a second pair around the same words.

An abbreviation can use <abbr title="World Health Organization">WHO</abbr>. Also write its full form visibly the first time it appears. A tooltip alone is hard to access on touchscreens and is not a reliable explanation for every reader.

Show code and preserve its spacing

<code> identifies a short piece of code within a sentence. For a block whose spaces and line breaks matter, combine it with <pre>:

<pre><code>&lt;p&gt;Welcome.&lt;/p&gt;</code></pre>

The reader sees the literal paragraph markup. <pre> preserves formatting, but it does not switch off HTML parsing. You must still represent < as &lt; and an ampersand as &amp; when they should appear as text. Otherwise a code example may be interpreted as actual page markup.

Mark dates, notation and other useful meanings

<sub> and <sup> express subscript and superscript where the notation needs them: H<sub>2</sub>O and m<sup>2</sup>. They are not tools for making unrelated text smaller.

<time> connects readable date or time text to a machine-readable value:

<time datetime="2026-03-14">March 14, 2026</time>

The datetime value uses year-month-day. A time can use the 24-hour value 14:30, even if the visible words say "2:30 p.m.".

Use <mark> for text highlighted because it is relevant in the current context, such as a search match. <small> holds side comments or fine print. A <span> carries no built-in meaning; it is useful for a language attribute or a styling hook within a line.

Key Takeaways

  • Use emphasis for stress and strong for importance.
  • Use <i> and <b> for their meanings, not simply their default styles.
  • <blockquote> and <q> mark quotations; <cite> marks a work title.
  • Expand abbreviations visibly, even when an abbr title supplies the full form.
  • <pre> preserves spacing but still parses HTML; escape literal code characters.
  • Use <time> with a machine-readable value and notation elements where their meaning fits.

2.3 Lists and their structure

A real list gives related items a shared structure. Its markup lets readers hear that they are entering a list and how many items it contains. The kind of list depends on what the items mean.

Choose the list type

Use <ul> for items whose order does not change their meaning, such as ingredients. Use <ol> for a sequence or ranking where order matters. Both contain list items marked with <li>.

<ol>
  <li>Boil the water.</li>
  <li>Add the pasta.</li>
  <li>Cook for 10 minutes.</li>
</ol>

Reversing these steps would change the instructions, so an ordered list fits. A browser normally shows numbers for <ol> and bullets for <ul>. CSS can change those markers; the meaning of the list stays the same.

Do not fake a list with typed dashes and line breaks. Those characters can look similar, but they do not tell a screen reader that the items form a list. A navigation menu often uses an unordered list, while a breadcrumb trail uses an ordered list because its path has a sequence.

Nest a list within its item

In ordinary list content, the direct element children of <ul> and <ol> are <li> elements. Do not place a paragraph or another list directly between them. The standard also allows script-supporting elements, but those do not replace list items.

A nested list belongs inside the item it describes:

<ul>
  <li>Fruit
    <ul>
      <li>Apples</li>
      <li>Pears</li>
    </ul>
  </li>
  <li>Vegetables</li>
</ul>

First open the "Fruit" item. Add its nested list, close that list, then close the "Fruit" item. Now "Apples" and "Pears" are structurally attached to "Fruit". Putting the inner <ul> after the parent's </li> would lose that relationship. An <li> can also contain paragraphs, links and images.

Control meaningful numbering

An ordered list can continue or reverse a count:

MarkupEffect
<ol start="4">First two ordinary items are numbered 4 and 5
<ol reversed>Counts down; five items start at 5 unless a start is set
<li value="10">Sets that item's number to 10; later items continue from it
<ol type="a">Uses letter markers when the marker type matters

reversed is boolean. It stays enabled in reversed="false"; remove it to resume counting upward. With type, the values 1, a, A, i and I select common numbering forms. Use a meaningful marker form when text elsewhere refers to a specific label, such as clause "b".

Pair terms and descriptions

A description list uses <dl>, with <dt> for a term or name and <dd> for its description or value:

<dl>
  <dt>Opening time</dt>
  <dd>08:30</dd>
  <dt>Closing time</dt>
  <dd>17:00</dd>
</dl>

One term may have several descriptions, and several terms may share one description. A group can be wrapped in a <div>. Use this structure for name-value relationships, such as a glossary or product details, rather than forcing those pairs into unrelated bullet items.

Key Takeaways

  • Use <ul> when order does not matter, <ol> when it does, and <dl> for name-description pairs.
  • Place ordinary unordered and ordered list content in <li> elements.
  • A nested list belongs inside the parent list item.
  • start, reversed, value and type control ordered-list markers.
  • Real list markup preserves relationships that typed bullets cannot express.
3

Link pages and build navigation

Links connect a page to the rest of its site and the wider web. Their addresses must work from the page’s actual folder, and their words should tell people where they lead. Navigation turns those individual links into useful menus, contents lists and shortcuts. Trace destinations carefully, then make the page predictable for people using a mouse, keyboard or screen reader.

A link connects content to a destination. The browser works out that destination from the address you put in href, so choosing the right kind of URL is part of writing the link.

Write an anchor
<a href="https://www.w3.org/">World Wide Web Consortium</a>

The <a> element is an anchor. Its href is the destination and its content is the clickable link text. An anchor without href is a placeholder, not a working hyperlink. An image can also be its content.

An absolute URL supplies a scheme and domain, as in https://example.com/guide/. Use it to link to another website. href="www.example.com" lacks a scheme, so the browser treats it as a relative file path; it does not mean "open that website".

Work from the current folder

A relative URL starts from the current page's location. Consider this site:

site/
  index.html
  about.html
  recipes/
    index.html
    soup.html
  images/
    logo.png

From the home page, about.html reaches the neighboring About page and recipes/soup.html enters the recipes folder. From recipes/soup.html, the same about.html would look inside recipes/, where there is no such file.

Work through the path from recipes/soup.html to the logo:

  1. The starting folder is recipes/.
  2. ../ moves up to the site folder.
  3. images/ moves into the image folder.
  4. logo.png names the file.

The finished path is ../images/logo.png. Each additional ../ moves up one more folder. By contrast, index.html from the soup page reaches the recipes index, not the site's home page.

A root-relative URL starts with /, such as /about.html. On a web server it starts at the website root, whatever folder the current page uses. Opened directly from disk, that slash refers to the filesystem root, so it does not identify your project's site folder. Use ordinary relative paths for pages you also test directly from disk.

Paths use forward slashes and must match file names and capitalization. Many servers treat Soup.html and soup.html as different files. A folder link such as recipes/ normally asks a server for its default file, commonly index.html; direct disk browsing may show a folder listing.

Jump to a part of a page
<a href="#watering">Watering</a>
<h2 id="watering">Watering</h2>

The fragment begins with # in the URL. The target's id has no # and must match exactly. For another page, combine them: basil.html#watering. An empty fragment # goes to the top. #top also goes to the top when no matching element is found.

Open an email or phone destination

mailto:info@example.com asks the visitor's email app to compose a message. A subject can be included as mailto:info@example.com?subject=Table%20booking, with the space encoded as %20. tel:+15555550123 supplies a telephone destination in international format. The visible phone number may contain spaces even though this href does not.

Key Takeaways

  • Use <a href="..."> for a working hyperlink.
  • An absolute URL names the scheme and domain; a relative URL starts from the current folder.
  • Each ../ moves up one folder; a leading / starts at a server root.
  • A fragment matches a unique id, with # only in the URL.
  • mailto: and tel: identify email and phone destinations.

A useful link tells a person what to expect before they follow it. Its text, destination and opening behavior work together, including when the link is read by itself in a screen reader's link list.

Name the destination

Compare these links:

Weak wordingUseful wording
"Click here""Our lunch menu"
"Read more""Read the terrace opening announcement"
"Download""Lunch menu (PDF, 2 MB)"

Keep link text brief but specific. If two links have the same text, make them lead to the same destination. A bare URL is usually harder to read than a description, although an email address is useful link text when the address itself is the information.

A title tooltip cannot repair unclear visible wording. Touchscreen users may never see the tooltip, and keyboard access to it is unreliable. Put the important destination information in the link's actual content.

Signal files and downloads
<a href="menu.pdf" download="harbor-cafe-menu.pdf">Lunch menu (PDF, 2 MB)</a>

The text identifies the file type and size. The download attribute asks the browser to save the file and suggests a file name. It does not convert a page into a PDF. For ordinary web file links, the destination must be on the same origin for download to apply; special blob: and data: URLs are also supported. Browser settings and server headers can affect the final behavior, so the attribute is a request, not a promise of one exact dialog.

Let people control new tabs

Ordinary links open in the current browsing context, where the Back button can return to the previous page. target="_blank" requests a new tab or window. The new tab does not have the original tab's Back history, and a visitor may not notice the switch.

Use a new tab only when it serves a clear purpose, and announce it in the text:

<a href="https://example.com/archive" target="_blank" rel="noopener">Archive (opens in a new tab)</a>

Modern browsers give _blank links the protection of noopener: the opened page cannot use window.opener to control the original page. Writing rel="noopener" explicitly also covers older behavior. noreferrer additionally suppresses referrer information. nofollow communicates a search-engine relationship, not a navigation destination.

Make image links and larger links understandable

When an image is the only link content, its alt text supplies the link's name:

<a href="index.html">
  <img src="logo.png" alt="Harbor Café home page">
</a>

The useful information is where the link goes. Describing only the logo's colors would not name its destination.

An anchor can wrap a larger card containing a heading and paragraph, but it cannot contain another link or a button. Nested interactive controls give competing destinations or actions within one control.

A link goes somewhere: a page, a file or a page section. A button performs an action, such as opening a menu. href="#" is a top-of-page link; it is not a substitute for a button that performs an action.

Key Takeaways

  • Link text should name the destination and make sense on its own.
  • Identify linked file types and useful size information.
  • Announce new-tab behavior; noopener protects the original page.
  • For an image-only link, alt text names the destination.
  • Keep interactive controls separate: no links or buttons inside a link.
  • Use links for destinations and buttons for actions.

Navigation helps people find both the site page they want and the part of a long page they need. HTML can identify these groups so people using assistive technology can find them directly.

Give major navigation a region

Use <nav> around a major group of navigation links. A site menu commonly contains an unordered list:

<nav aria-label="Main">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="menu.html" aria-current="page">Menu</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

This markup belongs on the menu page: aria-current="page" identifies the link to the page currently shown. On the Contact page, move that attribute to the Contact link. Do not mark a section's index as the current page when the reader is viewing a different page inside that section.

The list makes the number and grouping of the links available to screen readers. Without CSS, the menu's items stack vertically. The <nav> element does not automatically arrange them in a row. A few unrelated footer links usually do not need a navigation region of their own.

Keep menus consistent across pages

Use the same items in the same order and location throughout the site. In a static HTML site, copying the menu means updating every copy when its contents change.

Check destinations from each page's actual folder. From recipes/soup.html, the home link is ../index.html; index.html would reach the recipes index. The words in the menu can stay the same while the relative paths change. A server-based site can use root-relative paths to avoid that folder dependence.

Build a table of contents

A contents list links to headings in the current page:

<nav aria-label="Contents">
  <ol>
    <li><a href="#planting">Planting</a></li>
    <li><a href="#care">Care</a></li>
  </ol>
</nav>
<h2 id="planting">Planting</h2>

Each fragment must match one unique id. Add a corresponding heading with id="care" for the second link. When several navigation regions have different jobs, labels such as "Main" and "Contents" let screen reader users distinguish them.

A breadcrumb trail is another kind of navigation. It shows a path such as "Home › Recipes › Tomato Soup". Use <nav aria-label="Breadcrumb"> with an ordered list and place the current page last. The order expresses the path through the site.

Provide a shortcut past repeated content

Put a skip link first in the body:

<a href="#main-content">Skip to main content</a>

Its target is the main region, written as <main id="main-content">. Keyboard users can follow that link to bypass a repeated menu. Keep the target id unique and spelled exactly as in the fragment. A skip link is a working navigation aid even before CSS changes its presentation.

Key Takeaways

  • Use <nav> for major navigation, with real lists and links.
  • aria-current="page" marks the link to the page actually displayed.
  • Keep menus consistent and recheck copied relative paths.
  • Label different navigation regions and match contents fragments to unique ids.
  • Put a skip link first in the body and point it to the main content.
4

Add images that everyone can understand

Images need more than a file name. The browser needs a correct address and dimensions, while readers need the information the image conveys. File format and compression affect how quickly the page loads; alt text and captions affect how well its meaning survives without the picture. Choose each part from the image’s purpose, whether it shows useful information, links somewhere or simply decorates the page.

4.1 Image files, dimensions and loading

An image in HTML remains a separate resource. The page tells the browser which file to fetch, how much space to reserve and what text can replace the image.

Add an image
<img src="images/harbor.jpg" alt="Fishing boats moored in the harbor at sunset" width="1200" height="800">

<img> is void, so it has no end tag. src gives a file address, with the same path rules used for links. alt provides a text alternative. If the picture fails to appear, check the folder, capitalization and file extension in src. A .jpg path does not identify a .png file, and .JPG can differ from .jpg on a server.

The image's bytes are not stored inside this HTML element. The browser downloads the file separately. Changing the HTML width does not make that downloaded file smaller.

Choose a format that fits the content
FormatUseful properties
JPEGCompact photographs; lossy compression and no transparency
PNGSharp graphics and screenshots; lossless compression and transparency
GIFSimple animation with a limited palette of up to 256 colors
SVGVector logos, icons and diagrams that stay sharp when scaled
WebP and AVIFModern formats that often reduce file size at similar quality

Current major browsers support WebP and AVIF. Choose an image based on the content and resulting file size, not only its extension. Lossy compression discards some detail to save space; lossless compression keeps the original image data.

Reserve the correct shape

The width and height attributes are whole numbers in CSS pixels, with no unit in the value. Write width="1200", not width="1200px". They let the browser reserve space before the file arrives, reducing layout shifts, where text jumps as an image loads.

A 1200 × 800 image has a 3:2 shape. Both width="1200" height="800" and width="600" height="400" preserve it. The second pair halves both dimensions. A 600 × 600 pair forces a square and distorts the picture. CSS can later control the displayed dimensions while preserving the ratio.

Reduce the file before using it

A phone photo at 4000 × 3000 has 12 million pixels and can occupy several megabytes. Resize it near its largest intended display size and choose sensible compression before adding it to the site. Otherwise every reader downloads the large file even when the page shows a tiny thumbnail.

For images further down a long page, loading="lazy" lets the browser wait until the visitor gets near them. Keep an immediately visible banner or main image on normal loading, since delaying it can make the page's first view slower.

Use images you own, have permission to use or can reuse under their license, with any required credit. Keep site images in your own site folder so another site's file changes do not break them. Content images belong in HTML; purely decorative background textures are usually handled by CSS.

Key Takeaways

  • src points to a separate file; <img> has no end tag.
  • Choose the format for the image content and file size.
  • Use numeric width and height values with the correct aspect ratio.
  • Resize and compress the actual file; display dimensions do not reduce its download size.
  • Lazy-load lower images, and use images with appropriate reuse permission.

4.2 Alt text, image purpose and captions

Alt text supplies the information a person needs when they cannot see an image. A caption supplies visible context for everyone. Choosing both begins with the image's purpose on this particular page.

Describe the useful information

For a photo that helps readers understand a place, describe what matters: alt="The café's terrace with six tables overlooking the harbor". A long inventory of every object is rarely useful. You usually do not need "Image of" because screen readers already announce the image role. A medium can matter, though, as in "Watercolor painting of the harbor".

Context changes the useful alternative. On an adoption page, the important details might identify a dog. On a park's visitor page, the same photo might communicate that dogs are welcome on the lawn. Ask what information a reader would lose if the image disappeared.

For a chart, give its main message and place detailed data nearby. For example, alt text can state that website visits rose from 1,200 in January to 3,000 in March. The surrounding text can give the full figures. A photographed sign or another image of text needs the relevant words in its alternative.

Distinguish informative, decorative and functional images
Image purposeAlt approach
Gives informationDescribe that information in context
Adds decoration onlyUse an empty value, alt=""
Alone inside a linkName the destination or function
Shows meaningful textInclude the words shown

An empty alt value is a deliberate instruction to skip a decorative image. Omitting the attribute is different: some screen readers may announce the file name instead. Use an alt attribute on every image you author.

A logo that is the only content of a home link needs a useful link name, such as "Harbor Café home page". The reader needs to know the destination, not just that the logo contains blue waves. title is not a substitute: its tooltip is not reliably available to keyboard, touchscreen or screen reader users.

Add a caption with figure
<figure>
  <img src="images/old-harbor.jpg" alt="Sailing ships crowded along a stone quay" width="1000" height="667">
  <figcaption>The harbor around 1900. Photo: Port Town Archive.</figcaption>
</figure>

<figure> groups self-contained content and its optional visible caption. <figcaption> is the first or last child of the figure, with at most one caption per figure. A figure may hold several images, a code sample, a quotation or a diagram; it is not limited to photographs.

In this example, the alt text replaces what the photograph shows. The caption supplies the date and credit. Copying the whole caption into the alt text would make a screen reader repeat that text without explaining the picture. A caption that merely says "Figure 1" also does not replace an image description.

Key Takeaways

  • Write alt text from the image’s purpose in context.
  • Use alt="" for decoration; do not omit the attribute.
  • An image-only link needs alt text that names its destination.
  • Give a chart’s main message and provide detailed information nearby.
  • A figure caption adds visible context; it does not replace alt text.
5

Structure pages with semantic elements

A complete page combines the document skeleton with meaningful regions and well-chosen content elements. Decide what is repeated site information, what is unique to this page and which pieces could stand on their own. Then connect that plan to a clear heading outline and source order. Building a small recipe page brings together metadata, text, navigation, images and checks before any visual layout is added.

5.1 Page regions and landmarks

A page contains regions with different jobs: an introduction, navigation, its unique content and supporting information. Semantic elements name those jobs so the structure is useful beyond its visual layout.

Name each region
ElementContent role
<header>Introduction to the page or its nearest section or article
<nav>A major navigation group
<main>The page's unique main content
<aside>Content indirectly related to its surroundings
<footer>Information about the page or the section it belongs to

A site header often contains a logo and menu. An article header can instead hold its heading, author and date. A footer can include contact details, related links or a copyright line. These elements identify roles, not a fixed set of words.

Keep the main content distinct

A normal page uses one visible <main>. Its content is unique to the page, so repeating site navigation belongs outside it. Do not place main inside an article, section, aside, header, footer or nav. A recipe article can go inside main, not the other way around.

An aside is for supporting material that is only indirectly related. A set of related recipe links can be an aside; an essential step in the recipe cannot. The name "aside" does not place the content in a side column. Without CSS, these regions normally stack in source order.

<body>
  <header>
    <p>Harbor Café</p>
    <nav>...</nav>
  </header>
  <main>
    <h1>Our Menu</h1>
    <p>Everything is baked fresh each morning.</p>
  </main>
  <aside>
    <h2>Today's special</h2>
    <p>Tomato soup with fresh bread.</p>
  </aside>
  <footer>
    <p>&copy; 2026 Harbor Café</p>
  </footer>
</body>

The menu page's unique content sits in main. The surrounding site information stays outside it. The source reads sensibly from top to bottom before any columns, colors or positioning are added.

Understand landmarks

A landmark is a region assistive technology can expose as a navigation destination. Main and nav provide landmarks. A page-level header provides the banner landmark, and a page-level footer provides the content-information landmark. A header or footer nested inside an article, aside, main, nav or section does not provide those page-level landmarks.

An aside normally has a complementary role. A nested aside can still have that role; nesting it in an article does not by itself remove the meaning. Use it only for appropriate supporting content and keep the page's regions understandable.

<search> identifies a region containing search or filtering controls and results. It creates a search landmark and is supported in current major browsers. It is distinct from nav: searching for content and choosing a known navigation link are different jobs.

A header cannot contain a header or footer, and a footer cannot contain either one. Separate page-level regions from the headers and footers that belong to individual articles. Choosing the right names provides useful structure even when all the regions currently look like ordinary blocks.

Key Takeaways

  • Semantic regions name content roles and can expose landmarks.
  • Use one visible main region for content unique to the page.
  • Use an aside for indirectly related supporting content.
  • Page-level headers and footers have different landmark behavior from nested ones.
  • HTML region names do not position content; CSS controls layout.
  • Use <search> for a search or filtering region.

5.2 Articles, sections and neutral wrappers

A semantic choice tells readers what a block of content is. Ask how the content relates to the page before choosing a container; two boxes that look alike can need different elements.

Test whether the content stands alone

An article is a self-contained composition that could be shared or reused separately. A blog post, recipe, news story or reader comment can meet that test. An article usually has its own heading, but having a heading alone does not make a block an article.

A section groups one theme within a larger whole, normally with a heading. "Opening hours" and "How to find us" can be sections of a contact page. If the block has no clear theme and you cannot give it a sensible heading, section is probably the wrong choice.

<article>
  <h2>Growing Basil at Home</h2>
  <section>
    <h3>Planting</h3>
    <p>Choose a sunny place for the pot.</p>
  </section>
  <section>
    <h3>Care</h3>
    <p>Check the soil regularly.</p>
  </section>
</article>

Here the article is one complete growing guide, while its sections divide the guide into themes. This example fits a page whose main <h1> appears before the article.

Nesting also works in the other direction. A "Latest news" section may contain several independent articles. Comments can be articles nested in the article they respond to. The content relationship decides the nesting.

Keep heading levels in the page outline

A section does not restart heading levels. If a page uses <h1> for its topic and <h2> for a themed group, use <h3> for articles inside that group. Do not put a new <h1> in every nested section. Browsers and screen readers use the heading levels you actually write; a section wrapper does not repair a skipped level.

Use neutral wrappers when no meaning fits

<div> is a neutral block wrapper. <span> is a neutral wrapper within a line of text. They provide hooks for a class, a language attribute or later styling without claiming a special content role.

<p>Try <span lang="fr">pain au chocolat</span> today.</p>

The span identifies the French passage without introducing a new block. Building the entire page from generic divs loses useful roles, but turning every div into a section invents themes that are not present.

Choose by asking what the block does:

  1. Is it the page's unique content? Use main as the outer region.
  2. Is it a major navigation group? Use nav.
  3. Could it stand as a complete composition? Consider article.
  4. Is it a themed part with a heading? Consider section.
  5. Is it indirectly related support? Consider aside.
  6. Is it just a wrapper? Use div, or span within text.

<address> has a particular meaning too: contact information for the nearest article or for the page. An email link in a site's contact footer can belong there. A postal address mentioned as a historical fact or event venue does not become contact information merely because it contains a street name.

Key Takeaways

  • An article is self-contained; a section groups one theme.
  • Articles and sections can contain one another when their content relationships fit.
  • Keep heading levels consistent across the whole page.
  • Use neutral div and span wrappers when no semantic element fits.
  • Use address for page or article contact information, not every street address.

5.3 From a page plan to complete HTML

Plan the roles and reading order before typing a complete page. A simple wireframe names the regions, while a heading outline names the content inside them. Together they guide the elements and their nesting.

Map the content

For a recipe page, put the repeated site name and menu in a header, the recipe in main and the site information in a footer. The recipe is self-contained, so an article fits inside main. Its outline is "Tomato Soup" with "Ingredients" and "Method" beneath it.

The page below lives in a recipes/ folder. Its home page and image folder are one folder up:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tomato Soup – Harbor Café Recipes</title>
  </head>
  <body>
    <a href="#main-content">Skip to main content</a>
    <header>
      <p><a href="../index.html">Harbor Café</a></p>
      <nav>
        <ul>
          <li><a href="../index.html">Home</a></li>
          <li><a href="index.html">Recipes</a></li>
        </ul>
      </nav>
    </header>
    <main id="main-content">
      <article>
        <h1>Tomato Soup</h1>
        <p>Published <time datetime="2026-03-14">March 14, 2026</time></p>
        <figure>
          <img src="../images/tomato-soup.jpg" alt="A bowl of red tomato soup with a swirl of cream" width="1200" height="800">
          <figcaption>Ready in 30 minutes.</figcaption>
        </figure>
        <h2>Ingredients</h2>
        <ul>
          <li>1 kg ripe tomatoes</li>
          <li>1 onion</li>
          <li>500 ml vegetable stock</li>
        </ul>
        <h2>Method</h2>
        <ol>
          <li>Chop the onion and tomatoes.</li>
          <li>Simmer them in the stock for 20 minutes.</li>
          <li>Blend until smooth.</li>
        </ol>
      </article>
    </main>
    <footer>
      <p>&copy; 2026 Harbor Café</p>
    </footer>
  </body>
</html>
Follow the choices in the code

The skip link is first in the body and targets the main region's unique id. The header contains the repeated site identity and navigation. The recipe article has the page's single main heading, followed by two equal <h2> sections.

Ingredients use an unordered list because changing their display order does not change what is required. The method uses an ordered list because the steps form a sequence. The photo's alt text replaces the picture; its caption supplies preparation context.

../index.html goes up to the home page. index.html stays in the recipes folder. Neither menu link is marked aria-current="page", because the displayed page is the soup recipe, not either index.

Check the finished page

Read the source from top to bottom. Its order should work for a keyboard user and a screen reader before CSS rearranges anything. Check the title, heading outline, single visible main, link paths and image alternatives. Run the HTML checker and fix its messages, then test the links and images in the browser.

Across several pages, keep the same repeated header, menu and footer. Give each page its own title and main heading, and adjust relative paths from its folder. Colors, fonts, spacing and columns can then be added through CSS without changing the roles you have already established.

Key Takeaways

  • Plan regions and a heading outline before writing the complete page.
  • Build the document in a sensible reading order and keep repeated site content consistent.
  • Check paths from the actual page folder and match the skip link to main.
  • Validate the syntax, inspect the content and test the finished page before styling.

HTML examples

5 Walkthroughs

1

Build and check a document

16 steps
Build a small visitor page while tracing its elements, metadata, language settings and browser repairs.
  1. 1
    IntroductionFrom text to a document

    A browser builds a page from the roles you mark in HTML. A paragraph is not just a line of text: its element tells the browser how that content belongs in the document.

    Build a visitor page in stages. First read its tags and attributes, then add its head and language settings, and finally check what happens when one piece of nesting is wrong.

  2. 2
    ExampleRead one paragraph

    Start with <p>Visit the community garden.</p>. The start tag is <p>, the words are its content, and </p> closes it. Together they form one element.

    Now write <p class="intro">Visit the community garden.</p>. The class attribute adds a name inside the start tag. Quoting the value keeps it together if you later add another class name.

  3. 3
    ExampleAdd importance inside the paragraph

    Mark only the needed phrase:

    <p>Bring your <strong>entry pass</strong>.</p>
    

    The paragraph is the parent, and strong is its child. Read the closing tags from inside outward: strong closes first, then p. This nesting becomes part of the browser’s DOM tree; changing indentation alone would not change the relationship.

  4. 4
    ChallengeFix two class names

    An author writes <p class=welcome note>Hello.</p>, intending the paragraph to have both class names. How should the attribute be written?

    ---reveal---

    Write class="welcome note". Without quotes, the class value stops at the first space and the browser treats note as another attribute. Both class names belong in one quoted value, separated by a space.

  5. 5
    Key InsightPresence can be the value

    A boolean attribute is enabled by being present. <ol reversed> counts down, and so does <ol reversed="false">. Remove reversed to turn it off.

    Void elements follow another useful rule: <br>, <img> and <meta> have no content or end tag. Writing a closing image tag does not give an image a second boundary; it introduces an error.

  6. 6
    ExampleCreate the outer document

    Start the visitor page with its declaration and two main containers:

    <!DOCTYPE html>
    <html lang="en">
      <head>
      </head>
      <body>
      </body>
    </html>
    

    The doctype selects standards mode. The head will hold information about the document, while the body will hold the content people read. Both are element children of the html root.

  7. 7
    ExampleFill in the head

    Add these lines inside head:

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Visit – Community Garden</title>
    

    The early charset declaration tells the browser how to decode text. The viewport line supports device-width layout. The specific title identifies this page in the tab; it is not the visible heading you will put in body.

  8. 8
    ChallengePlace the visible heading

    The tab should say "Visit – Community Garden" and the page should visibly begin "Visit the Garden". Where do those two texts go?

    ---reveal---

    Use <title>Visit – Community Garden</title> in head and <h1>Visit the Garden</h1> in body. They have different jobs. Putting the h1 in head may trigger browser recovery, but it does not give the document correct source structure.

  9. 9
    ExplanationState the text’s language

    The root’s lang="en" identifies the page’s main language. A Spanish welcome within it can have its own setting:

    <p><span lang="es">Bienvenidos</span> to the garden.</p>
    

    A screen reader can switch pronunciation for that passage. Language tags describe the content, not the country where the reader is located. Use a more specific tag only when that distinction fits the text.

  10. 10
    ExampleMake stored text match UTF-8

    A charset declaration is a reading instruction, not a converter. Save the file as UTF-8 in the editor and keep <meta charset="utf-8"> early in head.

    For text such as "Café", an encoding mismatch may display several wrong characters or a replacement symbol. Check both the actual saved encoding and the declared encoding. A server’s encoding header takes precedence over the meta setting.

  11. 11
    ChallengeShow markup as text

    The visitor page should display "Use

    for paragraphs." as an explanation. How can its source include that sentence without creating another p element?

    ---reveal---

    Write <p>Use &lt;p&gt; for paragraphs.</p>. The references display angle brackets as characters. UTF-8 supports ordinary accents directly, but it does not stop a literal less-than sign from beginning HTML markup.

  12. 12
    ExampleInspect an unexpected list

    Suppose the body includes this source:

    <p>Facilities:
      <ul><li>Water tap</li></ul>
    </p>
    

    The browser closes the paragraph when it reaches ul because a list cannot be paragraph content. The Inspector will therefore show a different structure from the nesting suggested by the source. Looking acceptable on screen is not a syntax check.

  13. 13
    ExampleRepair the source relationship

    Separate the introductory paragraph and the list:

    <p>Facilities:</p>
    <ul>
      <li>Water tap</li>
    </ul>
    

    Now the list follows the paragraph instead of being placed inside it. Run the HTML checker after saving. If it reports many errors, fix the earliest one and check again; one missing quote or end tag may account for several later messages.

  14. 14
    ChallengeChoose the useful comparison

    A paragraph appears empty in the Inspector even though the source seems to wrap a list. What two views help you diagnose that, and what relationship should you check?

    ---reveal---

    Compare View Page Source with the Elements or Inspector DOM view. Check whether the source incorrectly places a list inside p. The browser can close the paragraph before that list, making the parsed tree differ from the authored nesting.

  15. 15
    ChallengeReview the saved visitor page

    A page has the correct title and language, but a sentence reads "Café" and the checker reports a missing quotation mark near a link. What should you investigate for each problem?

    ---reveal---

    Check the file’s saved encoding against its UTF-8 declaration and any server header for the garbled text. Fix the missing attribute quote and revalidate for the markup errors. Language settings do not convert bytes, and a clean-looking page does not repair your source.

  16. 16
    RecapKeep the three checks distinct

    Read the elements and attributes to check structure. Match the saved text encoding to its declaration and use language attributes for language. Compare source, the DOM and checker messages when the result is unexpected.

    Save changes before refreshing the browser. Syntax validation is one check; reading the page’s headings, link words and image descriptions for meaning is another task you still need to do.

2

Turn a short article into structured text

14 steps
Build an article outline, add meaningful inline text and organize a list with subordinate items.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionGive readers a map
  2. 2
    ExampleStart with the outline
  3. 3
    ExampleAdd the paragraphs
  4. 4
    ChallengeReturn to a main section
  5. 5
    ExplanationMark a warning for its meaning
  6. 6
    ExampleQuote a short piece of advice
  7. 7
    ExampleExplain code without running it
  8. 8
    ChallengeSeparate visible and machine-readable dates
  9. 9
    ExplanationChoose a collection or sequence
  10. 10
    ExampleKeep related items together
  11. 11
    ChallengeContinue a numbered procedure
  12. 12
    ConnectionPair labels with information
  13. 13
    ChallengeReview the article choices
  14. 14
    RecapRead the structure aloud
3

Connect a small site without broken routes

13 steps
Trace paths from a nested page, improve its link names and build navigation with working in-page targets.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionConnect pages and page sections
  2. 2
    ExampleLocate the starting folder
  3. 3
    ExampleMove up, then select the destination
  4. 4
    ChallengeTrace a deeper path
  5. 5
    ExplanationMake the destination clear
  6. 6
    ExampleAnnounce a new tab
  7. 7
    ChallengeChoose navigation or an action
  8. 8
    ExampleBuild the site menu
  9. 9
    ExampleAdd a local contents route
  10. 10
    ExampleCreate a route past the menu
  11. 11
    ChallengeFind the incorrect current marker
  12. 12
    ChallengeReview a copied navigation block
  13. 13
    RecapCheck every route from its starting page
4

Choose an image and give it a useful alternative

10 steps
Prepare a page photograph, reserve its shape and choose text that fits the image’s role.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionPrepare the file and its meaning
  2. 2
    ExampleLocate the entrance photograph
  3. 3
    ExampleReserve the same shape
  4. 4
    TipReduce bytes before adding markup
  5. 5
    ChallengeChoose loading for two positions
  6. 6
    ExplanationWrite for the image’s job
  7. 7
    ExampleSeparate a caption from the alternative
  8. 8
    ChallengeName a logo link
  9. 9
    ChallengeReview a lower-page figure
  10. 10
    RecapReview the image without seeing it
5

Build a page from a content plan

12 steps
Choose regions and content containers, then assemble a small event page in a sensible reading order.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionPlan an event page
  2. 2
    ExampleChoose the outer regions
  3. 3
    ExplanationDistinguish page and article headers
  4. 4
    ChallengeKeep main in the right place
  5. 5
    ExampleDecide whether the event stands alone
  6. 6
    ExampleWrite the heading relationships
  7. 7
    ChallengeChoose contact markup by purpose
  8. 8
    ExampleAssemble the page from outside inward
  9. 9
    ExampleConnect the content inside main
  10. 10
    TipKeep page copies consistent
  11. 11
    ChallengeReview the complete structure
  12. 12
    RecapRead before styling

HTML practice questions

50 Practice Questions in 5 sets

Set 1: Read and build a small web page10 Practice Questions

Question 1 of 10

What browser view shows the parsed element tree after automatic markup repairs?
  1. The page source view.
  2. The Elements panel.
  3. The Downloads list.
  4. The bookmarks bar.
Show answerHide answer
Answer: B
The Elements or Inspector panel shows the DOM the browser actually built, including parsing repairs. View Page Source shows the HTML received before those repairs. Comparing the two can reveal an element the browser closed earlier than you intended.

Question 2 of 10

Where does <title>Trail Map – Pine Park</title> belong in a normal document?
  1. Inside the first heading in the body.
  2. Inside the navigation before its links.
  3. Inside the footer after the copyright.
  4. Inside the head alongside metadata.
Show answerHide answer
Answer: D
The title belongs in the head because it supplies document metadata used in the tab, bookmarks and history. The visible page heading belongs in the body. Putting the title inside that heading confuses the document name with the content readers see.

Question 3 of 10

An English page contains one paragraph in Spanish. What attribute belongs on that paragraph?
  1. lang="es"
  2. lang="en"
  3. dir="es"
  4. charset="es"
Show answerHide answer
Answer: A
lang="es" identifies the paragraph as Spanish, allowing language-aware tools to handle it correctly. The root can keep the page’s English default. dir sets text direction, so it cannot replace a language tag.

Question 4 of 10

A page has an <h1> called "Repair a Bicycle" and an <h2> called "Check the Brakes". What level fits a new subsection called "Adjust the Cable" inside that brakes section?
  1. h1
  2. h2
  3. h3
  4. h4
Show answerHide answer
Answer: C
The cable topic is a subsection of the level-two brakes section, so it needs a level-three heading. Another h2 would make it a peer of the brakes section. Choosing h4 for a smaller default appearance would skip a level in the outline.

Question 5 of 10

A page gives assembly steps that must be completed in sequence. What structure fits the steps?
  1. A <ul> containing <li> items.
  2. An <ol> containing <li> items.
  3. A <dl> pairing <dt> and <dd>.
  4. A <p> containing <br> breaks.
Show answerHide answer
Answer: B
An ordered list expresses that the sequence matters, with each step in an li element. An unordered list can group the same words but would not express their required order. Typed numbers inside a paragraph also lose the real list structure.

Question 6 of 10

The file guides/cycling.html needs a link to contact.html in the site’s top folder. What relative href reaches it?
  1. ../contact.html
  2. contact.html
  3. guides/contact.html
  4. ../../contact.html
Show answerHide answer
Answer: A
The current folder is guides, so ../ first moves to its parent, the site’s top folder. contact.html then selects the target file. Using only contact.html would search inside guides, not beside that folder.

Question 7 of 10

A link opens a 900 kB PDF of a museum’s visitor map. What link text clearly describes it on its own?
  1. "Click here for visitor information"
  2. "Read more about visiting today"
  3. "Museum visitor information here"
  4. "Museum visitor map (PDF, 900 kB)"
Show answerHide answer
Answer: D
"Museum visitor map (PDF, 900 kB)" names the destination and signals a file download or opening. A screen reader’s separate link list can still convey its purpose. "Click here" gives an action but leaves the destination unclear without surrounding text.

Question 8 of 10

A photograph is 1500 × 1000 pixels. What attribute pair displays it at a width of 450 pixels while preserving its shape?
  1. width="450" height="450"
  2. width="450" height="1000"
  3. width="450" height="300"
  4. width="450" height="225"
Show answerHide answer
Answer: C
The original ratio is 3:2, so a width of 450 needs a height of 300. Both dimensions are scaled by the same factor. A height of 450 makes a square, which distorts this rectangular photo even though the requested width is correct.

Question 9 of 10

A small flourish adds no information between two paragraphs. What alt attribute should its <img> have?
  1. No alt attribute.
  2. alt="Flourish"
  3. alt="decoration.png"
  4. alt=""
Show answerHide answer
Answer: D
An empty alt value tells assistive technology to skip an image that adds decoration only. Naming the flourish would add unnecessary spoken content. Omitting the attribute is different from an empty value and can cause a screen reader to announce the file name.

Question 10 of 10

A gallery page repeats the same site menu on every page. Its unique content is one exhibition description, with optional related reading. What structure best separates these roles?
  1. Menu in nav; exhibition in main; related reading in aside.
  2. Put the menu in aside; put the exhibition inside a nav region.
  3. Put the exhibition in header; put the menu inside the main region.
  4. Put the menu and exhibition in main; put related reading in footer.
Show answerHide answer
Answer: A
The site menu is major navigation, the exhibition is unique page content, and optional related reading is supporting material. These roles fit nav, main and aside respectively. Moving the repeated menu into main would blur the page’s unique content with site-wide navigation.
Set 2: Choose markup that matches the content10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

What happens to a three-item list written as <ol reversed="false">?
  1. It counts upward from 1 to 3.
  2. It hides the numbers on all items.
  3. It counts downward from 3 to 1.
  4. It counts downward from 0 to −2.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Why does <p>Keep <em>this</p></em> have incorrect nesting?
  1. The paragraph closes before its child em closes.
  2. The em element starts after the paragraph begins.
  3. The em element contains text instead of an attribute.
  4. The paragraph has more than one word inside it.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A notice says "You must return the key" and marks the instruction as important, without changing which word receives spoken stress. What element fits the important instruction?
  1. <mark>
  2. <em>
  3. <i>
  4. <strong>
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

An article must show the literal code <em>go</em> with its spacing preserved in a code block. What markup achieves that?
  1. <pre><code><em>go</em></code></pre>
  2. <pre><code>&lt;em&gt;go&lt;/em&gt;</code></pre>
  3. <code><pre><em>go</em></pre></code>
  4. <p><code><em>go</em></code></p>
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

On events.html, the site menu links to Home, Events and Contact. Which link should carry aria-current="page"?
  1. The Home link.
  2. The Contact link.
  3. The Events link.
  4. All three links.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A page at https://example.com/help/topics/edit.html links to ../index.html#files. Where does the link lead?
  1. https://example.com/index.html#files
  2. https://example.com/help/index.html#files
  3. https://example.com/help/topics/index.html#files
  4. https://example.com/help/topics/edit.html#files
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

What format is a vector choice for a simple site logo that must stay sharp at different sizes?
  1. JPEG
  2. GIF
  3. PNG
  4. SVG
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A "Community News" section contains three complete stories that could each be republished independently. What element fits each story?
  1. <article>
  2. <nav>
  3. <span>
  4. <address>
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A static site repeats a header and footer on five pages. What page identity should still be specific to each page?
  1. The same title with a different meta charset.
  2. The same h1 with different global class names.
  3. Its own document title and main h1 heading.
  4. Its own doctype and a different file encoding.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An author expects <aside> to appear in a right-hand column, but it appears below the main text. What explains this?
  1. The aside must be changed to a nav element.
  2. Semantic role and CSS position are separate.
  3. The aside must be moved into the head element.
  4. The main element prevents all side columns.
Show answerHide answer

Save this lesson to see this answer.

Set 3: Find problems in a working page10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An HTML file has a long head, and its complete charset declaration ends at byte 1500. What change fixes the declaration’s placement?
  1. Move the charset declaration into the body.
  2. Replace the declaration with an html title attribute.
  3. Keep it there and add a second title before it.
  4. Move the declaration to the start of the head.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A file is saved as Windows-1252, contains accented words and declares UTF-8. There is no server encoding header. The browser shows replacement characters. What addresses the underlying mismatch?
  1. Add lang="en-US" without resaving the file.
  2. Resave as UTF-8 and retain the UTF-8 declaration.
  3. Change each paragraph into a pre element.
  4. Move the same charset declaration into the body.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

An HTML checker reports many errors after a link. The link begins <a href="notes.html>Notes</a>. What should you fix first?
  1. The unclosed href quotation mark.
  2. The number of letters in the link text.
  3. The absence of a class on the anchor.
  4. The absence of a title on the anchor.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

What element marks a content line break between the lines of a poem?
  1. <p>
  2. <hr>
  3. <br>
  4. <hgroup>
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

What numbers appear for the three items in <ol start="6"><li>A</li><li value="11">B</li><li>C</li></ol>?
  1. 6, 7, 8
  2. 6, 11, 8
  3. 1, 11, 12
  4. 6, 11, 12
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A site logo is the only content of a link to the home page. What alt text gives that link a useful name?
  1. "Meadow Garden home page"
  2. "Image of the garden logo"
  3. "Garden logo: logo.svg"
  4. "Green circle, white leaf"
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A page has a main menu, a contents list and a skip link first in the body. The skip link is href="#reading", while main has id="article". What change makes the skip link reach the main region?
  1. Give the link title="article" instead.
  2. Give nav aria-current="reading" instead.
  3. Change main’s id to reading.
  4. Give main class="reading" but keep its id.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A photo’s caption is "Bridge inspection, June 2026." The photo shows a crack across a support. What useful alt text adds the image’s information?
  1. "Bridge inspection, June 2026"
  2. "A crack running across a bridge support"
  3. "Photo called bridge-inspection.jpg"
  4. "Picture with a caption underneath"
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A page has h1 "Local History", then h2 "Transport", containing independently reusable stories. A wrapper around the stories exists only for styling and has no theme of its own. What story element, story heading level and wrapper fit?
  1. Section for each story, h3 for its heading and div for the wrapper.
  2. Article for each story, h2 for its heading and div for the wrapper.
  3. Article for each story, h3 for its heading and div for the wrapper.
  4. Article for each story, h3 for its heading and section for the wrapper.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

After a page passes syntax validation, what check can still find a content problem that validation cannot judge?
  1. Judge the alt text in its page context.
  2. Count the quotation marks in attributes.
  3. Check each void element for an end tag.
  4. Check every element name for spaces.
Show answerHide answer

Save this lesson to see this answer.

Set 4: Trace structure, paths and page behavior10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

An author writes <p id="notice" class=intro important>Bring ID.</p> and later <aside id="notice">...</aside>. What two edits give the paragraph both intended classes and keep identifiers valid?
  1. Quote class="intro important"; give the aside a different id.
  2. Quote class="intro"; give both elements the id "important".
  3. Quote class="intro important"; keep both ids as "notice".
  4. Keep the class markup; change the aside to class="notice".
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A browser shows a list after an introductory sentence, but the source puts the whole list inside a paragraph. Why is the display not evidence of valid nesting?
  1. The browser ignores all list tags in paragraphs.
  2. The browser converts every paragraph into a div.
  3. The browser can close the paragraph before the list.
  4. The browser treats all list items as headings.
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

The heading sequence is h1 "Birdwatching", h2 "Equipment", h3 "Binoculars", h4 "Focus", then "Locations", a new main section. What level fits "Locations", and why?
  1. h3, because it must remain under Binoculars.
  2. h4, because equal size means equal rank.
  3. h5, because each new heading goes deeper.
  4. h2, because it is a peer of Equipment.
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

What does <cite> identify in HTML text?
  1. The name of the person who spoke a quotation.
  2. A work’s title, such as a book’s name.
  3. The destination URL of every hyperlink.
  4. The spoken stress on a word in a sentence.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A three-item list uses <ol reversed start="9">; the second item has value="5". What are the displayed item numbers?
  1. 9, 5, 6
  2. 3, 5, 4
  3. 9, 5, 4
  4. 9, 8, 7
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A page is at https://example.com/library/topics/birds.html. It must link to the element id="access" in https://example.com/visit.html. What relative href does that?
  1. ../../visit.html#access
  2. ../visit.html#access
  3. ../../visit.html?access
  4. ../../visit.html/access
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A home-page menu is copied unchanged into journal/entry.html. Its Home link is href="index.html"; its Journal link is href="journal/index.html". What relative href pair reaches the top-level home and the journal index from the entry?
  1. Home index.html; Journal journal/index.html.
  2. Home ../index.html; Journal ../index.html.
  3. Home ../../index.html; Journal index.html.
  4. Home ../index.html; Journal index.html.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A page displays a 6 MB photograph at a small size using width and height attributes. Why does it still download 6 MB?
  1. The attributes choose an uncompressed format.
  2. The attributes change display size, not file bytes.
  3. The attributes force the browser to load it twice.
  4. The attributes remove all image compression.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

An image shows the words "Use the north entrance" on a temporary sign. The sign’s message is needed to enter the building. What should its alt text convey?
  1. "Temporary rectangular sign"
  2. "Sign with printed words"
  3. "Use the north entrance"
  4. "File in the images folder"
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

An article has its own header containing its heading and date, inside the page’s main region. What landmark behavior does that header have?
  1. It is not the page’s banner landmark.
  2. It becomes a second main landmark.
  3. It becomes the page’s navigation landmark.
  4. It replaces the outer page banner landmark.
Show answerHide answer

Save this lesson to see this answer.

Set 5: Review a site before adding CSS10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A paragraph should give strong importance to only the phrase "access code" and carry both classes "notice" and "urgent". What markup meets both requirements with correct nesting?
  1. <p class="notice urgent"><strong>Keep the access code.</strong></p>
  2. <p class="notice urgent">Keep the <strong>access code</strong>.</p>
  3. <p class=notice urgent>Keep the <strong>access code</strong>.</p>
  4. <p class="notice urgent">Keep the <strong>access code.</p></strong>
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A page has a visible heading "Accessibility" but its browser tab still says "Untitled". What edit addresses the tab while keeping the visible heading?
  1. Add title="Accessibility" to the body.
  2. Change the h1 element to a header element.
  3. Put another h1 element inside the head.
  4. Change the head’s title text to "Accessibility – City Museum".
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

What HTML source displays the literal sentence Use <aside> here as paragraph content?
  1. <p>Use <aside> here</p>
  2. <p>Use &amp;aside; here</p>
  3. <p>Use &lt;aside&gt; here</p>
  4. <p>Use &quot;aside&quot; here</p>
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A page quotes one short sentence inside a paragraph, then names the novel it came from and its author. What combination marks the quotation and the work title correctly?
  1. Put the sentence in q, the novel title in cite and the author in ordinary text.
  2. Put the sentence in q, the author in cite and the novel title in ordinary text.
  3. Put the sentence in cite, the novel title in q and the author in ordinary text.
  4. Put the sentence in blockquote inside p, the novel title in cite and the author in q.
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A page lists "Tools" and "Materials" as peer categories whose order is unimportant. Tools contains a two-step setup procedure that must run in sequence. What outer list and nested structure express those relationships?
  1. Use outer ul; put the inner ol directly beside the Tools li.
  2. Use outer ul; put the inner ul inside the Tools li.
  3. Use outer ol; put the inner ol inside the Tools li.
  4. Use outer ul; put the inner ol inside the Tools li.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A page at https://example.com/notes/entry.html needs an external link to https://example.org/help. The author writes href="example.org/help". Where does the written link resolve, and what fixes it?
  1. It resolves on example.org; add a fragment to select its help section.
  2. It resolves under example.com/notes; use the full https URL for example.org.
  3. It resolves at example.com/help; add ../ before the written path.
  4. It resolves at example.org/notes; begin the path with a slash instead.
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A control expands a page’s FAQ answer without navigating anywhere. What HTML control fits that action?
  1. An anchor with href="#".
  2. An anchor without an href.
  3. A button element.
  4. A nav element.
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A long page has a photo visible immediately and a gallery far below. Both use large camera originals and omit dimensions. What plan improves downloads and loading stability without delaying the first photo?
  1. Resize and compress files, add ratio-correct dimensions, and lazy-load only the lower gallery.
  2. Keep originals, add ratio-correct dimensions, and lazy-load both the first photo and gallery.
  3. Resize files, omit dimensions, and lazy-load only the first photo above the gallery.
  4. Keep originals, set square dimensions, and lazy-load only the lower gallery.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A paragraph mentions the street address where a historic festival took place. It is not contact information for the page or an article. Does <address> fit that mention?
  1. Yes, because every street address needs address markup.
  2. Yes, because address supplies a geographic location role.
  3. No, because address can appear only in a page header.
  4. No; a venue mention is not contact information.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A recipe at recipes/stew.html links Home with index.html, marks the recipes index as aria-current="page", and puts a necessary cooking step in aside. What review plan fixes all three content relationships?
  1. Keep Home, remove aria-current and move the cooking step into the footer.
  2. Use ../index.html for Home, keep aria-current and move the step into main.
  3. Use ../index.html for Home, remove the incorrect current marker and put the step in the recipe.
  4. Use /recipes/index.html for Home, mark it current and put the step in the recipe.
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

99 Key Terms, each with its definition

A

Abbreviation
An abbreviation is a shortened form marked with abbr; a title attribute can give its expansion, which should also be visible when introduced.
An abbreviation such as "WHO" is clearer when its full form appears in the surrounding text.
Absolute URL
An absolute URL supplies a complete web destination, including its scheme and domain, without needing the current page's folder.
The absolute URL https://example.com/help names both the website and the target path.
Alt text
Alt text is an image's text alternative, supplied by alt to convey its information or function when the image cannot be seen.
Useful alt text describes the key information a diagram adds to the surrounding paragraph.
Alternative voice
An alternative voice sets text apart as a term, thought or foreign phrase without adding stress emphasis, using i.
An alternative voice can mark a Latin species name while lang identifies its language.
Article
An article is a self-contained composition that can stand alone or be reused independently, such as a story, recipe or comment.
Each complete story in a "Latest news" section can be marked as an article.
Aside
An aside contains indirectly related supporting content, such as related links, without taking essential explanation out of the main flow.
An aside can suggest other articles while the current article remains understandable on its own.
Aspect ratio
An aspect ratio is the relationship between an image's width and height that must be preserved to avoid distorting its shape.
A 1200 × 800 image and a 600 × 400 display share the same 3:2 aspect ratio.
Attribute
An attribute supplies extra information about an element and is written inside its start tag after the element name.
The href attribute on a link gives the address the browser should open.

B

Base text direction
The base text direction sets a passage's overall left-to-right or right-to-left direction, affecting punctuation and mixed text.
An Arabic page uses dir="rtl" to set its base text direction alongside lang="ar".
Block quotation
A block quotation is a longer quoted passage set apart with blockquote; visible attribution belongs outside the quoted content.
A block quotation can carry a source URL in cite while a following paragraph names the work.
Body
The body is the part of an HTML document that holds its page content, including headings, paragraphs, images and navigation.
A visible main heading belongs in the body, even though it names the page.
Boolean attribute
A boolean attribute is enabled by its presence and disabled by its absence, regardless of a false-looking value.
The boolean attribute reversed still reverses numbering when written as reversed="false".
Breadcrumb trail
A breadcrumb trail shows a page's position along a site's hierarchy, using ordered navigation with the current page last.
The breadcrumb trail "Home › Journal › Spring Walk" shows how the article sits within the site.
Browsing context
A browsing context is a place a browser displays a document, such as a tab or window selected by a link's target.
The target value _blank requests a new browsing context instead of the current one.
Button
A button is an interactive control for an action, such as expanding content, rather than navigating to a different destination.
A button fits an FAQ control that opens an answer without taking the reader elsewhere.

C

Character encoding
A character encoding is the set of rules used to turn characters into stored bytes and decode those bytes back into text.
An encoding mismatch can make accented text appear as unexpected characters.
Character reference
A character reference represents a character using HTML syntax beginning with an ampersand, such as < for a less-than sign.
The character reference &lt; lets a page show an opening angle bracket without beginning a tag.
Citation title
A citation title is the name of a work, such as a book or film, marked with cite rather than using it for a person's name.
The citation title in "I read Frankenstein" can be marked with the cite element.
Code element
The code element identifies computer code within text or inside a preformatted block, without itself preserving all source spacing.
A sentence uses the code element when naming the markup needed for a paragraph.
Contact address
A contact address is contact information for an article or page, marked with address rather than every street address mentioned.
An article's contact address can contain an email link for its author.
Contextual highlight
A contextual highlight marks text relevant in its current setting through mark, such as a matching search term.
A contextual highlight can point out a search match without declaring it urgent.
Current-page marker
A current-page marker identifies the link to the displayed page through aria-current with the value page.
Move the current-page marker to Contact when the visitor opens the contact page.

D

Decorative image
A decorative image adds appearance without needed information, so an HTML image used that way has an empty alt value.
A decorative image of a flourish uses alt="" so it adds no spoken clutter.
Description list
A description list groups names with descriptions or values, using dl around groups of dt and dd elements.
A description list can pair "Closing time" with "17:00" in a site's contact details.
Description term
A description term is a name or label marked with dt inside a description list, followed by one or more descriptions.
The description term "Encoding" can be followed by a dd that explains how text becomes bytes.
Description value
A description value supplies a term's explanation or associated information through dd within a description list.
A description value can give a definition for the dt immediately before it.
Div
A div is a neutral block container used when no semantic element fits, often to group content for styling or layout.
A div can group two boxes for later CSS without claiming they form a themed section.
Doctype
The doctype is the declaration at the start of an HTML document that tells a browser to use standards mode.
The page begins with <!DOCTYPE html> before its root element and metadata.
Document title
The document title names a page in the browser tab, bookmarks and history, using a title element in the head.
"Access – City Museum" is a document title that distinguishes the page from the site home.
DOM
The DOM, or Document Object Model, is the browser's tree representation of a document after parsing its HTML.
The Inspector shows the DOM, which can include repairs absent from the received source.
Download attribute
The download attribute requests that a linked resource be saved and can suggest a file name, subject to browser and origin rules.
A same-origin PDF link can use the download attribute with a suggested document name.

E

Element
An element is a structural unit of HTML, usually consisting of a start tag, content and an end tag.
The element <p>Welcome.</p> identifies "Welcome." as a paragraph of page content.
Error recovery
Error recovery is the browser's rule-based handling of incorrect markup, allowing it to build a page despite source errors.
Error recovery may close a paragraph automatically when the browser encounters a list.

F

Figure
A figure groups self-contained content, such as an image, diagram or code sample, with an optional caption using figure.
A figure can keep an archive photograph together with its visible date and credit.
Figure caption
A figure caption is visible explanatory text marked with figcaption as the first or last child of its figure.
A figure caption supplies a photo's date while the alt text describes what the photo shows.
Fine print
Fine print is side-comment content such as a legal note or copyright line, marked with small because of its meaning.
A copyright note can be fine print even when CSS changes how large it appears.
Footer
A footer supplies information about its page or section, such as contact details, author information or a copyright notice.
On a recipe page, a page footer can repeat the site contact details without becoming part of the recipe.
Fragment
A fragment is the part of a URL after a hash sign that can name a target element by its unique id within a document.
The fragment #care points to id="care", with the hash sign only in the address.
Functional image
A functional image performs a role such as a link's sole content, so its alternative names the destination or action.
A functional image linking to Home needs a home-page name, not just its logo's colors.

G

Global attribute
A global attribute can be used on HTML elements generally, such as id, class, lang, title or hidden.
The global attribute id can identify a heading or the main region as a fragment target.

H

Head
The head is the part of an HTML document that contains metadata about the page, separate from its visible body content.
A document's head holds its character declaration, title and linked stylesheet.
Header
A header introduces its page or nearest section or article, often holding a heading, identity information or navigation.
A page header can hold a site logo, while an article header can hold its title and date.
Heading group
A heading group combines a heading with related introductory text such as a subtitle, using hgroup and paragraph content.
A heading group keeps "Harbor Café" and its tagline together without inventing another section.
Heading hierarchy
A heading hierarchy expresses how page topics and subtopics fit together through the ranks of h1 through h6 elements.
A heading hierarchy can place "Equipment" at h2 and "Binoculars" beneath it at h3.
Heading outline
A heading outline is the ordered set of a page's heading levels and topics, revealing how its content is grouped.
For a recipe page, a heading outline with Ingredients and Method under the recipe's title guides the page's finished markup.
HTML
HTML is the markup language that gives web content its structure and meaning through elements and their attributes.
A browser reads HTML to distinguish a page's headings, paragraphs, links and images.
HTML validation
HTML validation checks markup against HTML rules and reports problems such as invalid nesting, duplicate ids or missing attributes.
HTML validation can flag a missing alt attribute but cannot judge whether its wording is useful.
Hyperlink
A hyperlink is a connection to a destination created by an anchor element with href and clickable text or other content.
A hyperlink labeled "Opening hours" can lead to a neighboring page in the same site.

I

Image license
An image license states reuse permissions and conditions for an image, including any required attribution to its creator.
Check an image license before using a photo, then supply the credit it requires.
Image source
An image source is the file address supplied by an img element's src attribute, resolved with the same path rules as links.
Check the image source's folder and capitalization when a photo fails to load.
Inline quotation
An inline quotation is a short quotation within a sentence, marked with q so the browser supplies its quotation marks.
An inline quotation should not have another typed pair of quotes around the same words.

L

Landmark
A landmark is a meaningful page region that assistive technology can offer as a direct navigation destination.
A screen reader's landmark list can let a visitor jump to main or navigation.
Language tag
A language tag identifies the language of content, optionally including a region or script, as in en-US or zh-Hans.
The language tag fr-CA identifies French as used in Canada, not the reader's location.
Layout shift
A layout shift is movement of displayed content when space changes, such as when an image loads without reserved dimensions.
Giving an image width and height helps prevent a layout shift in the text beneath it.
Lazy loading
Lazy loading delays fetching an image until it is near the visitor's view, using loading with the value lazy.
Lower gallery images suit lazy loading, while a visible first-screen photo should load normally.
Line break
A line break moves text to a new displayed line within the same content block and is marked with the void element br.
A poem uses a line break where the next line belongs within the same verse.
Link text
Link text is the content that names a link's destination or purpose for readers, including when heard apart from its sentence.
The link text "Annual report (PDF)" is clearer in a link list than "Click here".
List item
A list item is an individual entry inside an unordered or ordered list, marked with li and able to hold further content.
A list item can contain its label and a nested list of choices beneath that label.
Lossless compression
Lossless compression reduces stored size while preserving image data, which is useful for sharp graphics and screenshots.
PNG uses lossless compression and supports transparency for a diagram's background.
Lossy compression
Lossy compression reduces file size by discarding some image detail, making a quality-size tradeoff useful for photographs.
JPEG uses lossy compression, so repeatedly reducing quality can remove visible detail.

M

Machine-readable date
A machine-readable date expresses a date in a standardized form for software, supplied by datetime on a time element.
A machine-readable date of 2026-03-14 can accompany visible text "March 14, 2026".
Main region
The main region contains content unique to the page and is marked with main, with one such region visible in a normal page.
The main region of a recipe page holds the recipe, not the menu repeated across the site.
Metadata
Metadata is information about a document, such as its title, character encoding or a short description of its contents.
The head's metadata helps the browser name the tab and decode the page text.

N

Navigation label
A navigation label names a nav region through aria-label so readers can distinguish groups with different purposes.
A navigation label of "Contents" distinguishes the page outline from the "Main" site menu.
Navigation region
A navigation region groups major navigation links using nav, allowing assistive technology to identify its purpose and location.
A navigation region can hold the site menu or the contents list of a long article.
Nested list
A nested list is a list placed inside an item of another list, expressing a subordinate group attached to that item.
Put a nested list of fruits inside the "Produce" li before closing that parent item.
Nesting
Nesting places one element inside another, creating parent-child relationships whose tags close from the inside out.
Correct nesting closes <strong> before closing the paragraph that contains it.
Non-breaking space
A non-breaking space keeps the words or symbols on either side together on one line instead of allowing a line wrap there.
In 10&nbsp;km, a non-breaking space keeps the number beside its measurement unit.
Noopener
Noopener is a link relationship that prevents a newly opened page from controlling the original page through its opener reference.
Writing rel="noopener" explicitly protects the opener, even though modern _blank links imply it.
Noreferrer
Noreferrer is a link relationship that suppresses referrer information and also provides protection against opener access.
A noreferrer link does not send the referring page's address to the destination.

O

Ordered list
An ordered list groups items whose sequence or ranking matters, using ol with li elements and meaningful numbering.
An ordered list fits assembly steps that must be carried out in a particular sequence.

P

Paragraph
A paragraph is a block of related text marked with p; separate paragraphs create content structure independently of source line breaks.
Two paragraph elements keep an introduction and a later explanation as distinct text blocks.
Preformatted text
Preformatted text preserves spaces and line breaks through pre, while still interpreting HTML markup within its content.
A preformatted code example still needs &lt; to display a literal less-than sign.

R

Relative URL
A relative URL describes a destination using the current document's location as its starting point, including parent-folder steps.
From a page in news/, the relative URL ../contact.html goes up to the contact page.
Root element
The root element is the top element of the document tree; in HTML it is html, enclosing the head and body.
The root element <html lang="en"> also states the page's default language.
Root-relative URL
A root-relative URL begins with a slash and resolves from a website's root on a server rather than the current page's folder.
The root-relative URL /about.html reaches the same site path from different folders.

S

Search region
A search region groups search or filtering content using search and provides a search landmark for assistive technology.
A site's search region has a different role from its menu of known destinations.
Section
A section groups one theme within a page or larger composition, normally with a heading that explains the group's subject.
An "Opening hours" section can sit beside "How to find us" on the same contact page.
Semantic element
A semantic element names the role or meaning of its content, allowing browsers and assistive technology to use that structure.
The semantic element nav identifies a menu more clearly than a generic div wrapper.
Skip link
A skip link is an early page link that lets keyboard users bypass repeated content and jump directly to the main region.
The skip link targets main's unique id so the visitor can pass a long repeated menu.
Source order
Source order is the sequence of content in the HTML, forming the reading order used by screen readers and keyboard navigation.
A sensible source order keeps an explanation before the related action even without visual styling.
Span
A span is a neutral inline container that can carry an attribute without assigning extra meaning to part of a sentence.
A span with lang="fr" can identify a short French phrase within an English paragraph.
Standards mode
Standards mode is the browser's normal rendering mode for modern documents, avoiding older quirks-mode layout behavior.
Including the modern doctype keeps a new page in standards mode.
Static site
A static site serves prepared page files; repeated menus and other shared content must stay consistent across those files.
In a small static site, changing a copied menu requires updating every page that contains it.
Stress emphasis
Stress emphasis highlights words whose spoken stress changes the meaning or focus of a sentence, using the em element.
Stress emphasis on "did" in "I did lock it" answers doubt about whether the action happened.
Strong importance
Strong importance marks text as important, serious or urgent through strong, independently of its default bold appearance.
A warning can use strong importance to identify the instruction that needs attention.
Subscript
A subscript is lowered notation marked with sub when its position has meaning, such as the number in a chemical formula.
The subscript 2 in H₂O identifies the number of hydrogen atoms in the formula.
Superscript
A superscript is raised notation marked with sup when its position has meaning, such as an exponent or squared unit.
The superscript 2 in m² expresses a squared unit instead of ordinary text sizing.

T

Table of contents
A table of contents lists page sections as links, usually targeting heading ids through fragments within the same document.
A table of contents can link "Planting" to the matching heading without opening another page.
Tag
A tag is the markup that starts or ends an element; an end tag includes a slash before the element name.
In a paragraph, the <p> tag starts the element and the </p> tag closes it.
Thematic break
A thematic break marks a change of topic or scene within text, using hr rather than merely drawing a decorative line.
A story can use a thematic break when its action moves to another place.

U

Unordered list
An unordered list groups items whose sequence does not affect their meaning, using ul with li elements for the items.
An unordered list suits ingredients because rearranging them does not change the collection.
URL scheme
A URL scheme identifies the kind of destination or protocol before the colon, such as https, mailto or tel.
The scheme mailto: asks an email app to compose a message to the address that follows.
UTF-8
UTF-8 is the required HTML character encoding and can represent every Unicode character, including accents and other scripts.
Saving and declaring UTF-8 lets a page display "café" without replacing its accent.

V

Vector image
A vector image describes shapes rather than a fixed pixel grid, allowing suitable artwork to scale without becoming blurry.
An SVG logo is a vector image that can remain sharp at several display sizes.
View Page Source
View Page Source is a browser view of the received HTML, before the parsed DOM's structure and automatic repairs are shown.
Compare View Page Source with the Inspector when an element appears under the wrong parent.
Viewport
The viewport is the browser area used to display a page; viewport metadata helps mobile layout use the device width.
The viewport meta element prevents many mobile browsers from shrinking a desktop-width view.
Void element
A void element is an HTML element with no content and no end tag, such as an image or a line break.
The image is a void element, so write <img> without a matching closing tag.

W

Wireframe
A wireframe is a simple page plan showing regions as boxes so their content roles can be decided before markup and styling.
A wireframe can label the header, menu, main content and footer before any code is written.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started