• in
InterCourses
CoursesBlogs
0
← Introduction to HTML
○What Is HTML? See Tags in Action○Exercise: Build the Meridian Signal○Complete HTML5 Page Structure: See It in Action○Exercise: Build a Complete HTML5 Page✦Module Quiz
○Heading Hierarchy Demo: H1 and H2○Exercise: Extend the Signal Brief○Paragraphs and Inline Tags Demo○Exercise: Write Meridian's Survey Notes○List Types Demo: Steps, Items, and Terms○Exercise: Build a Crew member Loadout○Challenge: Transmit a Rescue Signal✦Module Quiz
○Hyperlinks○Images○Applying Styles to HTML✦Module Quiz
●Div and Span○HTML Tables○Classes and IDs○Review: Structured Profile✦Module Quiz
○Project 1 - Visiting Card Structure○Project 1 - Visiting Card Actions✦Module Quiz
○The Head Element and Page Title○Meta Tags○HTML Entities✦Module Quiz
○Form Basics Demo: Join the Meridian Relay○Exercise: Build a Night-Shift Check-In○Input Types Demo: Build a Mission Profile○Exercise: Record Beacon Maintenance○Choice Controls Demo: Select Training Modes○Exercise: Plan a Supply Pickup○Response Controls Demo: Send a Mission Reply○Exercise: Build a Rescue Dispatch Report○Challenge: Send an Emergency Beacon✦Module Quiz
○Project 2 - Contact Us Form Structure○Project 2 - Contact Us Form Actions✦Module Quiz
○Embedding Video○Embedding Audio○Iframes✦Module Quiz
○Semantic HTML Tags○Details, Figure, and Figcaption✦Module Quiz
○Project 3 - Resume Semantic Structure○Project 3 - Resume Links and Actions✦Module Quiz

Div and Span

Mission

The community seed swap needs a simple swap-list page with two item cards. You'll group each item's information in a block container, then highlight one useful word inside a description.

What you'll build

A page with two stacked cards. Each card groups a title and description; a span marks a key word inside one description for future styling.

The two container jobs

Use <div> when a whole block belongs together. It begins on a new line and can hold headings, paragraphs, lists, and other elements. Use <span> when only part of a line needs a hook for styling or scripting.

TypeElementBehaviour
Block<div>Takes full width, starts on a new line, can contain any content
Inline<span>Takes only as wide as its content, sits within a line of text
html
<div class="card">
    <h2>Mint seeds</h2>
    <p>Good for a <span class="highlight">sunny</span> windowsill.</p>
</div>

The div keeps the item information together. The span stays inside the sentence, so it does not split the paragraph into another block.

Reusable hooks

A generic container has no appearance or meaning on its own. Add a class when several elements need the same treatment; use an id only for one unique element.

html
<div id="swap-list">
    <div class="card">Mint seeds</div>
    <div class="card">Terracotta planter</div>
</div>

card can label every card. swap-list identifies one page region. You will practice reusable classes and unique IDs in more detail later in this module.

Checkpoint

Run the page. Each card should start on its own line, while the span stays within its paragraph. Without CSS, the marked word will not look different yet. If everything runs together, check that each card is wrapped in its own opening and closing <div>.

Your Task

  1. Create a <div class="container"> that wraps all of the page content.
  2. Inside, add at least two <div class="card"> elements.
  3. Add a non-empty <h2> naming the item in each .card.
  4. Add a non-empty <p> describing the item in each .card.
  5. In one paragraph, wrap a key word in <span class="highlight"> for future styling.

Payoff

You now have a clean structure for a swap-list page: repeatable cards outside, a precise inline hook inside.

Hint 1
1 / 4
HINT 1
<div> is a block-level container — it takes up the full width and starts on a new line.
HINT 2

<span> is an inline container — it only takes up as much width as its content.

HINT 3

Both are 'generic' containers with no visual meaning on their own; style them with CSS.

HINT 4

Use class attributes to target divs and spans with CSS: <div class="card">

Loading editor…
READY
intercourses
html