CSS How To - Detailed Overview

How to Add CSS

There are three ways to apply CSS to an HTML document:

Inline CSS

Inline CSS is used to apply a unique style to a single HTML element. Example:

<p style="color: blue;">This text is blue.</p>

This text is blue.

Internal CSS

Internal CSS is used to define a style for a single HTML page, included in the <head> section. Example:

<head>
<style>
p {
    color: green;
}
</style>
</head>

This text is green.

External CSS

External CSS is used to define the style for multiple HTML pages. Example:

<link rel="stylesheet" href="styles.css">

This text is styled using an external CSS file.

Pseudo-classes

Pseudo-classes are used to define a special state of an element. Example:

a:hover {
    color: red;
}