Forum Moderators: not2easy

Message Too Old, No Replies

css and url length?

can the latter affect the proper functioning of former?

         

belenenses

9:17 pm on Sep 27, 2009 (gmt 0)

10+ Year Member



Hi Guys,

I’m in the early stages of building a new site with CuteHTML Pro 6, an HTML editor, at

<snip>

I’m want to be a bit more sophisticated and future proof with my page urls. So, instead of using for example:

http://www.example.com/Auvergne_best_hiking_trails.html

I want to use…

http://www.example.com/France/Trekking/Auvergne/Cantal_hiking_trails.html

and so have simply saved the Auvergne_best_hiking_trails file as
France/Trekking/Auvergne/Cantal_hiking_trails.html

However, whilst I’ve set up the required files on my system for France, Trekking and Auvergne, when testing it with the internal browser (I haven’t uploaded the last-mentioned page above yet) I get gobbledygook for design, as if the .css doesn’t take effect anymore.

Any reasons why? Are there restrictions on url length in such software? I wouldn’t have thought so judging by some of the urls I see.

Any feedback gratefully received.

Cheers!

ET

[edited by: swa66 at 9:43 pm (utc) on Sep. 27, 2009]
[edit reason] No URLs, use example.com, please see ToS and Forum Charter [/edit]

rocknbil

1:06 am on Sep 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get gobbledygook for design, as if the .css doesn’t take effect anymore.

Where is your CSS located in your file system, and what is your link to css?

If you have this

<link rel="stylesheet" href="style.css">

It tells us that style.css is located in the domain root, or at least in the same directory as the file with this line.

Move Cantal_hiking_trails.html to three directories deep,

/France/Trekking/Auvergne/

and it will no longer find style.css. Many coders concoct a relative path, like

<link rel="stylesheet" href="../../../style.css">

Which will work, but now your page is not "portable." Move it to another directory, or try to create a template from it that goes in the /France directory, and you have to constantly edit this path.

If you always start with a leading slash,

<link rel="stylesheet" href="/style.css">

It will find the style.css located at root no matter where you move the file. The leading slash means "Start from domain root" and will work for files in /France, /France/Trekking, or /France/Trekking/Auvergne.

Also works if you have css in a directory, as you should.

<link rel="stylesheet" href="/css/style.css">

The single down side to this approach is if you edit files offline, when you preview them it won't work because Windows/Mac is not a web server and doesn't know what to do with the leading slash - i.e., there is no domain root, it's just a directory and the browser includes all files relatively.

Take this one step further, into the url() selector in CSS. CSS url's are relative to wherever the CSS file resides.

url(images/mybackground.gif) top left repeat-y;

This will also break if the css file is in a css directory, as above. But the same approach will always find the images directory and the background.

url(/images/mybackground.gif) top left repeat-y;

belenenses

12:52 pm on Sep 28, 2009 (gmt 0)

10+ Year Member



Rocknbil,

It took me a bit of time to get my head around exactly what you were saying. After my eyes had glazed over a few times, I snapped out of the Monday blues and got down to implementing your ideas and suggestions.

I must say it has worked out a treat and I'm glad the kids weren't here to see dad dancing round the living room.

I thank you for your time, your clear and concise feedback and for allowing me quickly to get on with the job of making a living!

Cheers!

B.