Reputation: 4659
I am trying to link an external stylesheet to all my pages but it is not rendering. It works only on my homepage but not on other pages. I am using the exact same link on all pages and it is still not working. Any ideas on what I am doing wrong?
<head>
<title> Website name </title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
My CSS stylesheet has only these three selectors:
h1 {color:Red;}
div p {color: gray;}
body {background-color: yellow; font-family:arial;}
EDIT: I have h1 and div p on all pages.
Upvotes: 1
Views: 6485
Reputation: 17506
In one of the comments you say "My style sheet is in the main folder along with homepage. Subfolders have files of each pages.".
So assuming the site's folder structure is like
|- home.html
|- stylesheet.css
|- folder1
|------page1.html
|- folder2
|------page2.html
The link in home.html
should be
<link rel="stylesheet" type="text/css" href="stylesheet.css">
and the links in page1.html
and page2.html
should be
<link rel="stylesheet" type="text/css" href="../stylesheet.css">
This just means "the CSS file is one folder above the curent one".
Upvotes: 1
Reputation: 3662
Try it like this:
<link rel="stylesheet" type="text/css" href="/stylesheet.css">
inside your subfolder pages.
Upvotes: 2
Reputation: 157
Kindly check your root folder may be
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
Upvotes: 1
Reputation: 993
place css file inside a folder name it CSS
and place your css file inside it
And try this method
<head>
<title> Website name </title>
<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
</head>
If you still have problem then check your file name and extension are same in both files
Upvotes: 1