topskill.dev
CoursesTracks
0
All courses/Introduction to HTMLApplying Styles to HTML
Links and Images
4 / 5
← Introduction to HTML
○What Is HTML? See Tags in Action○Build the Meridian Signal○Complete HTML5 Page Structure○Build a Complete HTML5 Page✦Module Quiz
○Heading Hierarchy: H1 and H2○Extend the Signal Brief○Paragraphs and Inline Tags○Write Meridian's Survey Notes○List Types: Steps, Items, and Terms○Build a Crew Member Loadout○Challenge: Transmit a Rescue Signal✦Module Quiz
○Hyperlinks○Links between project files○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: Join the Meridian Relay○Build a Night-Shift Check-In○Input Types: Build a Mission Profile○Record Beacon Maintenance○Choice Controls: Select Training Modes○Plan a Supply Pickup○Response Controls: Send a Mission Reply○Build a Rescue Dispatch Report○Form validation and submission○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○A keyboard-friendly page✦Module Quiz
○Project 3 - Resume Semantic Structure○Project 3 - Resume Links and Actions✦Module Quiz

Applying Styles to HTML

The walking-club photos had dimensions, but the rest of the browser’s appearance was its default. This short CSS introduction shows where styling can live. The next course will teach CSS in depth.

The supplied book-exchange notice already has a heading, a paragraph, and a link to the empty style.css. Use the HTML tab for the first two changes and the CSS tab for the third.

CSS controls presentation. In color: blue;, color is a property, the colon separates its value, and the semicolon ends the declaration. A stylesheet rule puts declarations inside braces after a selector such as p. px means pixels. Here you need only color, font size, and background color.

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-size: 20px;
        }
    </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 {
    background-color: lavender;
}

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 pageA small single-page prototype
External fileWhole siteStyles shared by several pages

Check your page

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. This preview injects style.css automatically, so removing the <link> does not demonstrate a broken connection here. Keep the supplied link: an ordinary standalone page needs it. For this exercise, check the CSS rule and selected editor tab if a style does not change.

Edit index.html, press Run to inspect your page, then Submit to check the tasks. You can submit after each step; later tasks may still be incomplete.

Your Task

The starter index.html already links to style.css. Use the HTML tab for steps 1–2 and the CSS tab for step 3:

  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).

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 →
Files
  • ⋄index.html
  • ⋄style.css
Loading editor…