All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

CSS: purpose, inline, internal and external style sheets, and rules

Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript

CSS (Cascading Style Sheets) controls how HTML looks. You need to know why it is used, the three ways to add it, and how a rule is written (spec 8.1.1 to 8.1.3).

Practise this in the app: instant marking and a fix for every mistake. Free, no email needed to start.

Practise this lesson

Why CSS (8.1.1)

HTML describes the structure and meaning of content; CSS describes its presentation: colours, fonts, spacing and layout. Keeping them separate means:

Three ways to add CSS (8.1.2)

<!-- 1 Inline: a style attribute on one element -->
<p style="color: navy;">Opening times</p>

<!-- 2 Internal: a style element in the head -->
<style>
  p { color: navy; }
</style>

<!-- 3 External: a separate .css file linked in the head -->
<link rel="stylesheet" href="css/style.css">
MethodAffectsStrengths and weaknesses
InlineOne elementQuick for a single change, but mixes style with content and must be repeated on every element; highest priority
InternalOne pageUseful for a single page or a page-specific style, but other pages cannot share it
ExternalEvery page that links to itOne file controls the whole site: consistent, easy to update, cached by the browser. Best practice

Files, folders and rules (8.1.2, 8.1.3)

External style sheets are usually kept in a folder such as css, named in lower case without spaces (style.css), and linked with a relative path (css/style.css, or ../css/style.css from a page in a subfolder). If you save a style sheet under a new name, such as Q04FINISHED.css, update the href in the link element: Pearson's 2025 report noted pages that lost their styling because the link still pointed to the old name.

A CSS rule has a selector and a declaration block of property: value pairs, each ending with a semicolon:

h1 {
  color: #003366;
  font-size: 2em;
}

Here h1 is the selector, color and font-size are properties, and #003366 and 2em are values. A comment is written /* like this */.

Worked example

A site has 40 pages. The client wants every heading changed from blue to green. Compare the work needed with inline styles and with an external style sheet.

  1. Inline: every h1 on every page has its own style attribute, so up to 40 or more edits, with the risk of missing some.
  2. External: one rule, h1 { color: green; }, in one file updates all 40 pages at once.

Answer: An external style sheet makes the change once and keeps the site consistent.

Key idea: CSS separates presentation from structure, giving layout control and a consistent design. Inline styles one element, internal styles one page, external styles every linked page. A rule is selector { property: value; }.

Check yourself

  1. What is the main advantage of an external style sheet over an internal one?
    • It always overrides inline styles
    • One file can style every page of the site, so a change is made once
    • It does not need a link element
    • It can only style one element
    Show answer

    One file can style every page of the site, so a change is made once. An external sheet is shared by every page that links to it.

  2. In the rule `p { text-align: center; }`, what is the property? Type it exactly.
    Show answer

    text-align. text-align is the property and center is its value; p is the selector.

  3. Which element links an external style sheet?
    • `<style src="style.css">`
    • `<link rel="stylesheet" href="style.css">`
    • `<script href="style.css">`
    • `<css link="style.css">`
    Show answer

    `<link rel="stylesheet" href="style.css">`. link with rel="stylesheet" goes in the head.

  4. Describe one difference between an internal and an external style sheet.
    Show answer

    An internal style sheet is in a style element in the head and only styles that page, whereas an external style sheet is a separate file that can style many pages.. Internal: inside a style element in the page's head, affects only that page. External: a separate .css file linked to any number of pages, so the site stays consistent.

  5. A student saves the stylesheet as Q04FINISHED.css but the page loses all its styling. What is the most likely cause?
    • The link element's href still names the old file
    • CSS files cannot have capital letters
    • The page needs an internal style sheet as well
    • The doctype is wrong
    Show answer

    The link element's href still names the old file. The href must name the file actually saved.

  6. Which rule is written correctly?
    • h2 ( color: red, font-size: 20px )
    • h2 { color = red; font-size = 20px; }
    • h2 { color: red; font-size: 20px; }
    • { h2: color red; }
    Show answer

    h2 { color: red; font-size: 20px; }. Selector, curly brackets, property: value pairs separated by semicolons.

  7. Which way of adding CSS affects only a single element?
    • An inline style attribute
    • An internal style sheet
    • An external style sheet
    • A CSS framework
    Show answer

    An inline style attribute. Inline CSS is written in the element's style attribute.

Practise with instant feedback

Sources

Last updated 8 November 2026. Spotted a mistake? Tell us.