Ways to Add CSS to a Web Page


There are three main ways to add CSS to a web page.

Each method is useful in different situations.

The Three Ways to Add CSS

  1. Inline CSS
  2. Internal CSS
  3. External CSS

1. Inline CSS

Inline CSS is written directly inside an HTML element.

It is useful for quick testing but not for large projects.

Inline CSS changes only one element at a time.

2. Internal CSS

Internal CSS is written inside a style section in the HTML file.

It styles the whole page.

Internal CSS is good for small projects.

3. External CSS

External CSS is written in a separate file.

This is the professional way to style websites.

This file is saved as style.css.

Now the CSS styles the entire website.

Which Method Should You Use

  • Inline: For quick testing only
  • Internal: For small projects
  • External: For real websites

Why External CSS Is Best

External CSS:

  • Keeps code clean
  • Makes updates easier
  • Helps teamwork

Why This Matters for Jobs

Companies expect developers to use external CSS.

It is a professional standard.

Practice Task

Create a small HTML file and:

  1. Try inline CSS
  2. Try internal CSS
  3. Try external CSS

See the difference.

What You Will Learn Next

In the next lesson, you will learn how to write clean CSS using comments and formatting.