• 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

Applying Styles to HTML

Mission

Give a neighborhood book-exchange notice its first bit of visual hierarchy. Try one one-off heading color, one page-level paragraph rule, and a reusable page background.

What you'll build

A book-exchange notice with three style scopes: an inline heading color, an internal paragraph rule, and an external background color.

HTML gives you three ways to apply CSS to a page. Knowing the difference helps you choose the right one.

1. Inline styles

Add a style directly to one element with the style attribute:

html
<p style="color: blue; font-size: 18px;">This text is blue and slightly larger.</p>

When to use it: For a quick one-off override or styles applied dynamically with JavaScript.

Downside: Styles scattered through HTML are hard to update consistently.

2. The <style> tag (internal stylesheet)

Put CSS rules in a <style> block inside <head>:

html
<head>
    <style>
        h1 {
            color: darkblue;
        }
        p {
            font-family: Arial, sans-serif;
            line-height: 1.6;
        }
    </style>
</head>

When to use it: For a single-page project or when you want styles in one file.

Downside: You cannot share those styles across multiple HTML pages.

3. External stylesheet (<link>)

Create a separate .css file and link to it from <head>:

html
<head>
    <link rel="stylesheet" href="style.css" />
</head>

style.css:

css
body {
    font-family: Georgia, serif;
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    color: #333;
}

When to use it: For a real-world project with more than one page.

Benefits: One source of truth for styles and easier browser caching.

Which to choose?

MethodScopeBest for
InlineOne elementQuick overrides, dynamic JS styles
<style> tagOne pageSmall demos, email templates
External fileWhole siteAll real projects

Checkpoint

Preview after each change. The heading color should affect only the <h1>, the internal rule should change paragraph text, and the external stylesheet should change the page background. If the background stays unchanged, check that the stylesheet link points to style.css.

Your Task

The starter index.html already links to style.css. Edit that file for the last step:

  1. Add an inline style to the <h1> that sets color to any colour you choose.
  2. Add a <style> block in <head> that styles p — change the font-size to at least 16px.
  3. In style.css, add a body rule with a visible background-color (not transparent or white).

Payoff

The book-exchange notice now shows why scope matters: a local override, a page rule, and a reusable stylesheet can work together.

Hint 1
1 / 4
HINT 1

Inline styles go directly on an element: <p style="color: red;">text</p>

HINT 2

The <style> tag lives inside <head> and holds CSS for the whole page.

HINT 3

An external stylesheet is linked with: <link rel="stylesheet" href="style.css" />

HINT 4

External stylesheets are preferred — they separate content from presentation and can be reused.

Take the Quiz →
Loading editor…
READY
intercourses
html