Frontend Master

JavaScript Curriculum

Text on the Page
+35 XP

Text on the Page

easy
~22 min·35 XP

The Nexus portal needs a homepage with a welcome message, a mission statement, and some fine print. Before you can style anything, you need to mark up the content with the right elements — structure first, appearance second.

Text on the Page

The web is mostly text. Before CSS gave us colors and fonts, HTML's text elements did double duty: they conveyed meaning and appearance. Today, CSS handles appearance — but HTML still owns meaning. Choosing the right text element matters for search engines, screen readers, and other developers reading your code.

ℹ️Semantic vs Presentational
**Semantic** elements describe *what* content is. **Presentational** elements describe *how* it looks. HTML5 is entirely semantic — avoid elements like `<b>` and `<i>` (presentational) in favour of `<strong>` and `<em>` (semantic). A bold keyword and an important warning both look bold, but they mean different things.

Headings: Six Levels of Hierarchy

HTML gives you six heading levels, <h1> through <h6>. They create an outline of your page — a hierarchy that both humans and machines use to navigate.

headings.html

Click any heading to inspect its properties →

<h1>

Page title — one per page

Default size

32.00px

Em value

2em

Font weight

700 (bold)

ARIA level

level 1

When to use

The main topic of the entire page. Should match or relate to the <title>. Only ever use one h1.

Using multiple h1 elements confuses the document outline and is bad for SEO and screen reader navigation.

⚠️One h1 Per Page
A page should have exactly one `<h1>` — the primary topic. Search engines weight it heavily. Screen reader users can jump directly to headings to navigate the page. Never skip levels (don't jump from h2 to h4) and never choose headings based on font size — that's what CSS is for.

Inline Text Elements

Below the heading level, a set of inline elements add meaning to runs of text within a paragraph:

text-elements.html
<strong></strong>

Strong importance — bold

Semantic importance. Screen readers may stress it. Different from <b> which is purely visual boldness with no semantic weight.

Renders as:

Our freshly brewed espresso is made with single-origin beans.

HTML:

<strong>freshly brewed espresso</strong>

The Key Distinction: Inline vs Block

Every HTML element has a default display behaviour. Understanding this early makes CSS layout make sense:

display-types.html
Inline elements

Flow within text — only as wide as their content

Text flows with span, a, strong, em, code all on one line.
<span>inline
<a>inline
<strong>inline
<em>inline
<code>inline
Block elements

Stack vertically — stretch to full available width

<h2>Section Heading
<p>A paragraph of text…
<div>Generic container
<ul>• List item • item
<blockquote>"A blockquote"

💡 CSS display: block or display: inline overrides any element's default display type

💡strong vs b, em vs i
`<strong>` signals *importance* — semantic weight. `<b>` just bolds for stylistic reasons (like keywords in a doc, or product names). `<em>` signals *spoken stress* — the sentence means different things depending on which word is stressed. `<i>` is for idiomatic phrases, technical terms, or foreign words. Use the right one.

When to Use br

The <br> element should be reserved for content where line breaks are part of the meaning — not as a spacing hack. Good uses: postal addresses, poetry, and song lyrics. Bad use: two <br> tags to add space between paragraphs (use CSS margin instead).

html
<!-- Good address format requires specific line breaks --> <address> 42 Nexus Drive<br> San Francisco, CA 94102 </address> <!-- Bad use CSS margin on paragraphs instead --> <p>First paragraph.</p> <br> <br> <p>Second paragraph.</p>

Challenge

Mark up a company homepage section using semantic text elements. Use an h1 for the company name, an h2 for a tagline section, a paragraph with strong and em emphasis, a br for a short address, and small for legal disclaimer text.

headingsparagraphstrongembrsmallsemantic-htmlinline-vs-block
Text on the Page | Nexus Learn