Skip to content
techsnow

Introduction

Adding CSS to HTML

There are three ways to add CSS to a page.

1. External stylesheet (best)

Write your CSS in a separate .css file and link it from the <head>.

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

2. Internal stylesheet

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

3. Inline style

<p style="color: red; font-weight: bold;">Warning!</p>
MethodGood forDownside
ExternalReal websitesOne extra file to load (cached after the first visit)
InternalSingle-page demosCan't be reused on other pages
InlineQuick tests, emailsHard to maintain, overrides everything