The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> CSS stylesheet not connecting with file on localhost, href
james.R
post Apr 9 2017, 04:58 AM
Post #1





Group: Members
Posts: 4
Joined: 9-April 17
Member No.: 26,372



Hi All. I am new to the forum.

I have used external style sheets before but for some reason it will not connect on my local host. I hope someone can see what i am doing wrong.

I am using localhost and the hosted folder name is call htdocs. In here i have a few folders: crm, css, graphics, web ect

The file i am trying to connect the css on is login.php in the crm folder.

The css file for this is in the css folder and called login.css

I am trying to use the following to connect but having no luck.

CODE

<head link rel="stylesheet" type="text/css" href="http://localhost/css/login.css">


I have also tried the following variations

CODE

<head link rel="stylesheet" type="text/css" href="css/login.css">
<head link rel="stylesheet" type="text/css" href="localhost/css/login.css">
<head link rel="stylesheet" type="text/css" href="http://css/login.css">


Any help would be greatly appreciated.

Thanks

James
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 9 2017, 05:50 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



The CSS <link> should be in the <head> section (between <head> and </head>), not in the <head> tag itself.

This post has been edited by CharlesEF: Apr 9 2017, 05:51 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
james.R
post Apr 9 2017, 06:04 AM
Post #3





Group: Members
Posts: 4
Joined: 9-April 17
Member No.: 26,372



Thanks CharlesEF silly mistake on my end. Have corrected but still not working. First time using a local host and im trying lots of different combinations of the link to try and make it work.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
james.R
post Apr 9 2017, 06:08 AM
Post #4





Group: Members
Posts: 4
Joined: 9-April 17
Member No.: 26,372



Sussed it.
CODE

<head>
<link rel="stylesheet" type="text/css" href="\css\login.css">
</head>

I missed the "\" before the css\login.css
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
james.R
post Apr 9 2017, 06:08 AM
Post #5





Group: Members
Posts: 4
Joined: 9-April 17
Member No.: 26,372



Thanks for the help though i wouldnt have spotted that.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Apr 9 2017, 06:17 AM
Post #6


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Glad you got it working. When using paths in a web server it is always better to start the path with '/'. The '/' means to start in the root folder/directory. href="http://localhost/css/file.css" and href="/css/file.css" mean the same thing (also applies to 'src=').
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Apr 9 2017, 07:46 AM
Post #7


.
********

Group: WDG Moderators
Posts: 9,650
Joined: 10-August 06
Member No.: 7



QUOTE(james.R @ Apr 9 2017, 01:08 PM) *

CODE

<head>
<link rel="stylesheet" type="text/css" href="\css\login.css">
</head>

I missed the "\" before the css\login.css

Note that backslashes should only be used in Windows' local file system. On a server (local or on the web) you should use forward slashes as usual.

As a sidenote, you can use relative URLs as well, even though it's usually less practical. Since the login.php file is in the crm folder (a folder which is parallell to the css folder), you would then need to go up one level first:

CODE
<link rel="stylesheet" type="text/css" href="../css/login.css">

See also http://htmlhelp.com/faq/html/basics.html#relative-url
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 9 2017, 10:12 AM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I don't think backslashes should be used at all. Browsers are more lenient now, but do all browsers really accept them? It used to be only IE. And that was for local files. This is over a server, even if it runs on the same machine.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 02:32 AM