Read a CSS file outside a main folder - html

I have html file in main(X-folder) which has CSS also, and I convert HTML to asp and i need to put inside a ASP[Y] folder..
My question since my CSS file is in main folder[X] how can i access on to it. suppose i am in X folder
my problem is that my File in Y folder which is converted to .asp file when i access its url i lost majority of its image and styles
how can i re-write my css
i tried few; still its not read the CSS
this is an image which describe my problems
<link href="X/css/style.css" rel="stylesheet" type="text/css" media="all" />
<link rel="stylesheet" href="X/css/responsiveslides.css">
<link href="X/css/iframeCSS.css" rel="stylesheet" type="text/css">

Have you tried using a leading slash (/ at the start)? It indicates to load the resource from the root of the web server. For example, with <link href="/X/css/style.css" ... /> it will load from example.com/X/css/style.css.
You could also use ../, which indicates to load a resource from a directory below (up a level). So if you were in directoy Y/, you could do <link href="../X/css/style.css" ... /> which loads the resource, again, at example.com/X/css/style.css.

The stylesheets included in your page are using relative paths.
Specify your stylesheet links with
runat=server
and prefix them with the virtual web root path
(~)
For example :
<link href="~/X/css/style.css" rel="stylesheet" type="text/css" media="screen" runat="server" />

Related

CSS style sheet not found

i spent the last hour figuring out why my style sheet is working.
enter image description here
I tried every possible way, but none of it works.
It just shows error 404 when i check it in the developer mode of my browser.
I tried
<link href="style.css" type="text/css" rel="stylesheet" />
<link href="./style.css" type="text/css" rel="stylesheet" />
<link href="../style.css" type="text/css" rel="stylesheet" />
<link href=".../style.css" type="text/css" rel="stylesheet" />
I also placed the the css file in the same file as my header.php.
The path to the css file is a relative path from the file that's called from the browser, and that's most likely not header.php.
If you start the path with a / it's considered relative to the webroot, so you probably want /css/style.css. Note that you cannot go up (using ../) from the webroot.
../ is meant to go back a folder so if my folder layout is
Root
css
style.css
includes
header.php
I have ho down a folder and enter the css folder like:
<link rel="stylesheet" href="../css/style.css">
You are using many link tag to integrate the css file in you html file. You should use one tag and it would be a relative path like the following <link rel="stylesheet" href="/css/style.css">

I’m having trouble linking my CSS file to my html

I created the CSS folder and named it. I added this to my header in HTML but the changes aren’t happening.
<link rel="stylesheet" type="text/css" href="haiku-styles-shaun.css" />
You mentioned you've created a CSS folder. Then include that folder name in the href
<link rel="stylesheet" type="text/css" href="CSS_FOLDER_NAME/haiku-styles-shaun.css" />
Probably your CSS file isn't in the same directory as your HTML file, you provided the wrong name of your CSS file (also check that your CSS file's extension is .css). Solve these and try again.
You have to include each file you need separately.
e.g.:
<link rel="stylesheet" type="text/css" href="haiku-styles-shaun.css/myButton.css" />
<link rel="stylesheet" type="text/css" href="haiku-styles-shaun.css/myPhoto.css" />
<link rel="stylesheet" type="text/css" href="haiku-styles-shaun.css/myFooter.css" />
Most user don't need all their style definition at the same time. To save bandwidth you have to choose.
You said that you created a folder but you didn't write it on the path. Try adding the css folder before the file name like this:
<link ref="stylesheet" type="text/css" href="folder/file.css" />
Furthermore I suggest you to include versioning in your css to avoid browser caching when you refresh. To do that every time you update your css change the number at the end in the link:
<link ref="stylesheet" type="text/css" href="folder/file.css?v=1" />
The <link> tag is used to link to external style sheets. You have to use something like this :
<link rel="stylesheet" type="text/css" href="Folder-Name/Stylesheet-Name.css">
Make sure that your href address is setup properly otherwise it won't load in your HTML page .
Note: The element is an empty element, it contains attributes only.
Note: This element goes only in the head section, but it can appear any number of times.
In HTML the <link> tag has no end tag. In XHTML the tag
must be properly closed.

Template’s CSS is not styling the HTML

I've downloaded a template from w3layouts.com to make a website, and when I unzip the layout and try to open any of the HTML files, none of the CSS styling the page (it just looks as if there's no CSS).
When I inspect the HTML files, the CSS appears to be included in the header. For example, this is included in smartphone/blog.html's header:
<link href="smartphone/css/style.css" rel="stylesheet" type="text/css" media="all" />
You have to simply update this link tag
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
Because in this template href="smartphone/css/style.css". but actually css dictonary present in same level where other html file are. So you just update html file link tag to new href="css/style.css".
Is this template is for website, phone so you must set this template using index.php file to set dynamic path. but above solution is static not a dynamic. if you have to set dynamic path you must configure template step.

getting out of the directory when applying a tag

How do I get out of the current directory Dreamland ?
I have to use the following tag in the jsp page inside the directory Dreamland :
<link href="css/style.css" rel="stylesheet" type="text/css" />
Currently it is unable to locate the css directory.
<link href="../css/style.css" rel="stylesheet" type="text/css" />
../ means up one directory level, one ../ puts you in the Web Pages folder
You can try using /css/style.css, or ../css/style.css (if you are not using a server).

Firefox can't find external CSS using absolute file path

On my web page I have the following line in the <head> element:
<link type="text/css" href="C:/myApps/app1/images/css/12.02/main.css" rel="stylesheet" />
When I go to view that page in Firefox 11.0, it is obvious that the main.css is not being loaded. If I go to view page source, I see the <link> element (above) in the HTML, but when I click it I get the following error:
Firefox doesn't know how to open this address, because the protocol (c) isn't associated with any program.
How do I fix this?
try:
<link type="text/css" href="file:///C:/myApps/app1/images/css/12.02/main.css" rel="stylesheet" />
might work
Edit: as per the other answers, this is when you want to use a css file on your local machine, if the website will be hosted then you'll need to use a relative path.
<link type="text/css" href="images/css/12.02/main.css" rel="stylesheet" />
The above assumes that your html file with the link in is located in your "app1" folder.
Martyn
you need to insert an url/uri => file:///C:/myApps/app1/images/css/12.02/main.css
Hi you cas change your css path
<link type="text/css" href="C:/myApps/app1/images/css/12.02/main.css" rel="stylesheet" />
into
xxx.css replace into correct path
<link type="text/css" href="xxx.css" rel="stylesheet" />