The correct means to connect a CSS file to a HTML file is adding between the HTML tags at the height of the HTML web page. However before, tright here are many tiny mistakes that you have the right to make that have the right to lead to your HTML and CSS not linking properly. These are:

6 mistakes you are making when linking CSS to HTML and also exactly how to correct them.

You are watching: Why is my css not linking to my html


Lets look at each error you can be making and also how you deserve to link HTML to CSS correctly.

1. Using the wrong HTML tag to connect HTML to CSS.

You occasionally find people trying to use HTML tags to connect your CSS to HTML. This cannot work-related.

You can only usage HTML tags as soon as you are writing your CSS in the head section of a HTML record itself not linking the CSS file.

The correct HTML tag to connect a CSS file to a HTML file is utilizing the . The "main.css" is the name of the CSS file. Please note that the HTML tag is a self-cshedding tag and does not to come in pairs choose the or HTML tags.

2. Placing the CSS attach in the wrong part of the web page.

You will not have the ability to connect HTML and also CSS, if you place the HTML tag on any kind of various other component of the webpage other that inside the head tags.

So look at where you have actually placed your connect HTML tag and also change that appropriately.

3. Non-equivalent file name and attach href worth name

Check to make sure that your CSS file name is the exact same as the name suggested in the href value on the HTML tag. If you usage a various name, the internet browser will certainly look at the attach you have actually assigned to your HTML file. If it finds nopoint tright here, it does nothing. If the two perform not enhance, then you have discovered your culprit.

All you have to perform is readjust the href worth to the correct name of the CSS file.

4. Spaces in the CSS file name

When you have spaces in the CSS file namme name of file.css, the web browser will certainly not be able to correctly interprete the spaces in the href value .

To make this work, you have the right to either:

rearea the spaces in the href worth through %20. i.e. or replace the spaces in the CSS file name via hypen(-) or underscore(_) on both the file name and the href link value as a way to sepeprice words.

5. HTML and CSS file place on same or various folders

When your HTML and also CSS documents are not on the very same folder, you could have some difficulties linking them.You deserve to settle this difficulty by:

Using the correct file course to the CSS file. So if the CSS file is in a different folder from the HTML path, you have to recognize the course name and also include it to the attach href value. eg.If the css file is in a folder called styles that remained in the exact same folder as the HTML file, the correct route would certainly be . Moving the CSS and also HTML to the exact same folder. When you move them to the exact same folder, the connect href worth will ssuggest be the css file name: .

6. Syntaxes errors in your CSS file

If you have an error in the CSS file, it might bring about your CSS layouts not being used to the HTML code.The easiest way to correct this is to either:

Use a text editor via syntaxes highlighter. Syntaxes highlighting will certainly help you identify wbelow your code is not correct. Use an digital CSS validator tool. An digital CSS validator tool will tell you wbelow you have made a mistake in you CSS code.

See more: Angry Ex? He Broke Up With Me So Why Is He The Angry One Is Your Ex Unbelievably Angry

If you follow this overview, you will certainly constantly be able to affix your HTML and CSS files together.

Receive new content in your inbox

I sfinish out an email once I produce something new. Never before any kind of spam, quickly unsubscribe any time.