Click here to Skip to main content
14,607,026 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello,i am creating a website. I have already created my home page and i had no problem linking my home page html page with my css style sheet but i am having a problem linking my second html page with my css style sheet. By the way i have different css style sheet for different html page. Am i missing something?

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <meta charset="utf-8">
  <link href="" rel="stylesheet">
  <link rel="stylesheet" href="style/hair.css">
	<nav class="navbar">
	<span class="open-slide">
		<a href="#" onclick="openSlideMenu()">
		<svg width="30" height="30">
                <path d="M0,5 30,5" stroke="#F76C6C"
                <path d="M0,14 30,14" stroke="#F76C6C"
                <path d="M0,23 30,23" stroke="#F76C6C"

 <ul class="navbar-nav">
      <li><a href="index.html">Home</a></li>
      <li><a href="hair/hair.html">Hair</a></li>
      <li><a href="makeup/makeup.html">Make up</a></li>
      <li><a href="skincare/skincare.html">Skin Care</a></li>
      <li><a href="blog/blog.html">Blog</a></li>


What I have tried:

I have been looking online for a solution for more than two hours and i have tried everything that i know, i only just started coding so i don't know a lot.
Updated 8-Feb-19 0:41am
Prifti Constantine 7-Feb-19 3:28am
Which one goes where? Where does the cdn go and where the locan css file?
Mohibur Rashid 7-Feb-19 3:34am
is your first html and second html are in the same directory.
Member 14142347 7-Feb-19 4:45am
No they are in different directory
Richard Deeming 7-Feb-19 16:39pm
Did you remember to update the href in the stylesheet <link> to account for that?

HTML File Paths[^]

For example, if the HTML is in hair/hair.html and the stylesheet is in style/hair.css, then the link would be:
<link rel="stylesheet" href="../style/hair.css">

Note the ../ at the start which moves up to the parent directory.
Member 14142347 7-Feb-19 19:15pm
Thanks for the reply, I added ../ and it worked. Thank you
Bob@work 7-Feb-19 12:45pm
After creating a local CSS "/style/hair.css", and assigning the font-family "lobster" to everything, it seems to work. It takes a moment to load the Google font the first time. What does your local CSS file look like? Could it have an error preventing the desired appearance?

/* style/hair.css */
* {font-family:lobster;
Mohibur Rashid 7-Feb-19 21:53pm
I know you got your solution, but have you learned anything from this?
Member 14142347 8-Feb-19 1:45am
Yes, ../ means a directory two levels above the current one. So when I am trying to link a file that is in another folder I have add this ../
Mohibur Rashid 12-Feb-19 2:55am
not two level, one level
Say, you are in the following directory
> cd /var/www/html/
> ls *

index1.html address main.css as
another_dirctor/index2.html address as
since css belongs to the parent directory of another_dirctor/

you can avoid this whole and address the path in the same way anywhere in the project by putting absolute file path
say your host is
and in the root of the html project you have css/main.css
then your src can be

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

As discussed in the comments, adding a leading "../" to the path resolved the issue.
<link rel="stylesheet" href="../style/hair.css">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100