What is the difference between inline, internal and external CSS?

There are three ways to add CSS to HTML.

TypeWhereBest for
Inlinestyle attribute on one elementQuick tests, one-off change
Internal<style> tag in the headOne page only
ExternalSeparate .css file linked with <link>Whole websites. Best choice
<!-- inline -->
<p style="color:red;">Text</p>

<!-- internal -->
<style>
  p { color: red; }
</style>

<!-- external -->
<link rel="stylesheet" href="style.css">

External CSS is the best for real sites, because one file styles all the pages and the browser keeps it in the cache. See HTML Styles.


Learn more about the similar topics:
Tutorials
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Comments
HTML Symbols
Exercises & Assignments
Program to see difference between paragraphs & normal text with line break
Write a program to create a webpage to print values 1 to 5
Write a program to create a webpage to print your city name in red color.
Write a program to print a paragraph with different font and color.
Write an HTML program to display all six heading levels
Write an HTML program for text formatting (bold, italic, subscript, superscript)
Interview Questions & Answers
How to add comments in HTML?
How to add the copyright symbol to a web page?
What is the difference between strong and b tag in HTML?
What are HTML entities?
What is the difference between inline, internal and external CSS?