How to link a css file to HTML?

There are there ways to link CSS to HTML file.

1. Inline CSS: using "style" Attribute.

<p style="color: red; font-size: 16px;">This is a paragraph with inline CSS.</p>

2. Internal CSS: CSS rules within a <style> element in the <head> section of your HTML.

<style>
p {
color: blue;
font-size: 18px;
}
</style>

3. External CSS: Using "<link>" element an external CSS file linked to the HTML file.

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

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free