SeinopSys
SeinopSys

Reputation: 8937

HTML file linking between directories

My folder structure:

de/
    index.html
en/
    index.html
hu/
    index.html
img/
    image.png
style/
    stylesheet.css

How can I link to the css file in the style folder & the image in the img folder within the html file inside the de folder, whithout having to type the entire hostname like http://myhost.com/style/style.css?

Is it even possible?

Upvotes: 0

Views: 135

Answers (4)

Farzad Bekran
Farzad Bekran

Reputation: 489

you don't have to type the domain, you should use

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

but dont forget the first / as this will mean that the address is on the same domain as the page. this will also save you from maintenance problems if you ever change the directory structure of your website.

Upvotes: 1

Ram
Ram

Reputation: 41

The css file can be link in the html file as

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

Upvotes: 1

treecoder
treecoder

Reputation: 45091

../style/stylesheet.css

../img/image.png

Upvotes: 4

Simone
Simone

Reputation: 21272

You can use a relative path: ../style/style.css

Upvotes: 1

Related Questions