• 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

Classes and IDs

Mission

The makers' fair program page needs three quick-jump stops — about, projects, and contact — and a row of project cards. Give each stop a unique landing point while keeping the cards easy to style as a group.

What you'll build

A makers’ fair program with navigation links to three stops and reusable exhibit cards. One card gets a second class as a future styling hook.

One name or a reusable label

Use class for a label that can appear on many elements. One element can carry several class names, separated by spaces.

html
<div class="card">Solar oven</div>
<div class="card">Seed library</div>
<div class="card featured">Repair map</div>

In CSS, a dot selects a class:

css
.card {
    border: 1px solid #ccc;
    padding: 1rem;
}

.featured {
    background-color: gold;
}

Use id for one unique element on the page. An ID becomes an anchor target when a link uses # followed by that value.

html
<nav>
    <a href="#about">About</a>
    <a href="#projects">Projects</a>
    <a href="#contact">Contact</a>
</nav>

<section id="about"><h2>About</h2></section>
<section id="projects"><h2>Projects</h2></section>
<section id="contact"><h2>Contact</h2></section>

CSS uses # before an ID: #contact { ... }.

Checkpoint

Run the page and select each navigation link. It should land on the section with the same ID. If a link does not move, compare its href="#..." value with the section's id; they must match exactly.

Class vs. ID

classid
UniquenessReusableMust be unique
CSS selector.classname#idname
Multiple per elementYesOnly one id per element
Use forStyling groupsUnique landmarks, anchors

Your Task

Build the fair program in the starter:

  1. Add a <nav> with three anchor links: #about, #projects, #contact.
  2. Add three <section> elements, each with the matching id.
  3. Give each section a short <h2> label.
  4. Put at least one non-empty <div class="card"> inside each section.
  5. Give one of those cards a second class (e.g., class="card featured").

Payoff

Your fair page can now link directly to each stop and style every project card with one reusable label.

Hint 1
1 / 4
HINT 1

Apply multiple classes with a space: class="card featured large"

HINT 2

An id must be unique on the page — only one element can have any given id value.

HINT 3

Use class for styling multiple elements; use id for anchoring or uniquely identifying one element.

HINT 4

IDs double as anchor targets: <h2 id="contact"> can be linked with <a href="#contact">

Loading editor…
READY
intercourses
html