Pregunta

I know the subject line must sound really stupid. Of course you would locally develop HTML files - didn't know how to phrase it better since I'm a beginner at HTML+CSS.

So to get to the point:

I'm linking to images and pages on the HTML file I'm editing. However, when I open the HTML file in my browser locally the links are broken because I'm not using an absolute path. My preference is to use relative path because I'll be able to simply move my project file folder onto my server without having to change the URL paths in my HTML files.

My question is: How do I get the relative paths to point to where I want without having to list the entire drive directory?

Ex. My local HTML has the following line:

<img src="/images/logo.jpg">

But opening the local HTML file in my browser, the image is broken since it points to: file:///D:/images/logo.jpg

How do I get it to point to {local root}/images/logo.jpg instead?

¿Fue útil?

Solución

What I did was to install a local development server such as EasyPHP, and setting the proper root folder within my project folder. Setting the root folder tells the local server where the root is, and so any relative paths work as expected.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top