This can easily be achieved through the use of the html link element, but it can be hard to get your head around at first. To start with, open up your html document in Sublime Text. In the header section, add: . You want to change "PATHTOCSSHERE" with the path to the css file you are trying to link the html page to. If that css file is in the same directory (or folder) as the html page, it's as easy as typing in "style.css" with the name of the css file matching whatever you called yours. I just used style.css to simplify things :) However, if the css file is in another directory (say inside a folder called css) you would need to type out the path to it relative to the html document. In this case, you'd type "css/style.css". Generally, it's a good idea to store your css files in a css folder within the root directory (the highest folder of your page structure), as that keeps it easy to remember where you put them all later :p Here's an example of a full header from one of my pages. Hope I was able to help! If you still have questions, feel free to comment back :) Answer from Lachlan Mitchell on teamtreehouse.com
🌐
W3Schools
w3schools.com › html › html_css.asp
HTML Styles CSS
Tip: You can define a border for nearly all HTML elements. ... The CSS padding property defines a padding (space) between the text and the border. ... The CSS margin property defines a margin (space) outside the border. ... External style sheets can be referenced with a full URL or with a path relative to the current web page. This example uses a full URL to link to a style sheet:
🌐
Reddit
reddit.com › r/learnprogramming › adding external css file to html doc
r/learnprogramming on Reddit: Adding external css file to html doc
June 1, 2022 -

I feel stupid and like I have taking 3 steps back in my learning. I am trying to figure out the 3 different implementations of css. Doing External now. Just trying this super simple code, the colors did not show up in the browser like they did on w3schools.

<!DOCTYPE html>

<html>

<head>

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

</head>

<body>

<h1>This is a heading</h1>

<p>This is a paragraph.</p>

</body>

</html>

Is it because I don't have a css file on my computer? Do I need to download one? Copy and paste from somewhere? I don't get it. I prefer building with the css and html on the same document because I haven't learned how to do anything else yet. I have been able to follow tutorials fine but for some reason, now it's not clicking.

Discussions

How do i link my css stylesheet to my html?
🌐 forum.freecodecamp.org
0
September 30, 2017
HTML/CSS linking
Hey Lachlan, When you were telling me to link my HTML document using the link you gave me as an exmaple it wasnt working for me. Would it make a difference if i am using a PC laptop instead of a macbook? ... It could probably be a typo somewhere. For example, if your filenames aren't spelled correctly and things of that sort. ... i am still having some problems with linking my CSS ... More on teamtreehouse.com
🌐 teamtreehouse.com
2
October 20, 2013
Where should I add CSS to my file?
The link to the CSS goes in the section of your HTML file, and should look like this: Where the href bit is the path to your CSS file. Most likely you made a mistake in your file path and the browser can't access your CSS. More on reddit.com
🌐 r/webdev
13
0
August 20, 2024
Linking CSS stylesheet to index.html
Meaghan Worcester is having issues with: This might be obvious BUT I can't identify why my stylesheet is not linking to html. Here's the code: More on teamtreehouse.com
🌐 teamtreehouse.com
10
March 31, 2014
🌐
Mimo
mimo.org › glossary › css › linking-a-style-sheet
Linking a style sheet in CSS: Learn to Connect CSS to HTML
To apply styles to an HTML document, you need to connect it to a CSS file. The most common way to do that is by linking a style sheet using the <link> element in the HTML <head> section.
🌐
W3Schools
w3schools.com › css › css_howto.asp
How to add CSS
... With an external style sheet, you can change the look of an entire website by changing just one file! Each HTML page must include a reference to the external style sheet file inside the <link> element, inside the head section.
🌐
Skillstruck
support.skillstruck.com › knowledge › link-a-css-file-to-an-html-file
How to Link a CSS File to an HTML File
July 10, 2025 - While it is possible to include CSS code in an HTML file, it is best practice to write CSS code in its own file and import it to an HTML file. CSS files can be linked to HTML files using the <link> tag. The <link> tag goes between the <head> and </head> tags at the top of an HTML page.
Find elsewhere
🌐
Newline
newline.co › 30-days-of-webdev › day-10-how-to-link-css-to-html-inline-style-and-stylesheets
How to Link CSS to HTML: Inline style and Stylesheets
April 28, 2023 - If you add CSS via an External Stylesheet you are telling the browser to go download another file that has all the style rules; hence "external." You do this by adding a <link> element with an href attribute pointing to the CSS file.
🌐
W3Schools
w3schools.com › tags › tag_link.asp
HTML link tag
The <link> tag also supports the Event Attributes in HTML. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if you want ...
🌐
IONOS
ionos.com › digital guide › websites › web design › linking css to html
How do you link CSS to HTML? Guide with examples
January 5, 2026 - This method involves linking the HTML document with an external CSS file. Below, we provide an overview of the three methods: ... With this approach, styling instructions are placed directly within the source code using the style attribute. The defined properties apply only to a single HTML element, making it easy to give individual elements different designs within the same HTML document.
🌐
Codecademy
codecademy.com › forum_questions › 553bcfc6d3292f7e1b000760
How do I actually link a CSS stylesheet to a HTML sheet? | Codecademy
if the css file is in the parent directory of the html file the links becomes: <link rel="stylesheet" type="text/css" href="../style.css" /> .. goes up 1 directory, if you need two you could do: ../../ this is called relative path (you link ...
🌐
Simplilearn
simplilearn.com › home › resources › software development › how to link external css in html
How To Link External CSS in HTML | Simplilearn
December 2, 2025 - External CSS (file) is a form of CSS which is used to add styling to multiple HTML pages at a time. It helps to design the layout of many HTML web pages simultaneously. Read more!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Hostinger
hostinger.com › home › tutorials › how to link css to html files in web development
How to Link CSS to HTML Files: An All-You-Need-to-Know Guide
December 16, 2025 - To link CSS to HTML, use the <link> tag within the <head> section of your HTML document, which creates a reference to an external CSS file.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-link-css-to-html
How to Link CSS to HTML – Stylesheet File Linking
June 14, 2022 - To link your CSS to your HTML, you have to use the link tag with some relevant attributes.
🌐
HubSpot
blog.hubspot.com › home › website › how to add css to html: understanding inline, internal & external css
How to Add CSS to HTML: Understanding Inline, Internal & External CSS
March 13, 2023 - Then, put your CSS inside this file (you don’t need to wrap it in <style> tags). Next, open your HTML document. In the <head> section, add a link to this external stylesheet using the <link> element.
🌐
Simplilearn
simplilearn.com › home › resources › software development › linking css files to html: the ultimate tutorial for you
How to Link CSS to HTML: A Beginner’s Guide
September 17, 2020 - How to Link CSS to HTML? To link the CSS to an HTML file, we use the tag inside the HTML section. link-css-to-html.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › link
<link>: The External Resource Link element - HTML | MDN
1 week ago - The <link> HTML element specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both "favicon" style icons and icons for the home screen and apps on mobile devices) among ...