How to Add a CSS File to HTML
Create the CSS file., Upload your CSS file to your website. , Copy the URL of your CSS file., Add a link to the file., Save your HTML file, and upload it to your website. , Verify that everything on your site looks how it is supposed to look.
Step-by-Step Guide
-
Step 1: Create the CSS file.
Prepare and save your CSS file with the ".css" file type. -
Step 2: Upload your CSS file to your website.
, The URL might look like www.yoursite.com/stylesheet.css.
It's good form to remove the main domain name from the link (URL).
Therefore a URL of "http://mysite.com/css/default.css" would be shortened to "/css/default.css".
You must include that leading slash ("/").
This is called a relative path. , Find the </head> tag in your HTML file, and create an empty line just above the tag.
Add <LINK rel=stylesheet type="text/css" href="www.yoursite.com/stylesheet.css"> to that empty line, changing "www.your..." to the link to your CSS file. ,, If it doesn't, you may need to go back and look for any corrections or adjustments you need to make. -
Step 3: Copy the URL of your CSS file.
-
Step 4: Add a link to the file.
-
Step 5: Save your HTML file
-
Step 6: and upload it to your website.
-
Step 7: Verify that everything on your site looks how it is supposed to look.
Detailed Guide
Prepare and save your CSS file with the ".css" file type.
, The URL might look like www.yoursite.com/stylesheet.css.
It's good form to remove the main domain name from the link (URL).
Therefore a URL of "http://mysite.com/css/default.css" would be shortened to "/css/default.css".
You must include that leading slash ("/").
This is called a relative path. , Find the </head> tag in your HTML file, and create an empty line just above the tag.
Add <LINK rel=stylesheet type="text/css" href="www.yoursite.com/stylesheet.css"> to that empty line, changing "www.your..." to the link to your CSS file. ,, If it doesn't, you may need to go back and look for any corrections or adjustments you need to make.
About the Author
Cynthia Freeman
Committed to making organization accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: