html - img tag not working with relative path in src -


this not working:

<img src="../assets/images/image.jpg" alt="alternative text"> 

but working:

<img src="http://localhost/abc/def/geh/assets/images/image.jpg" alt="alternative text"> 

in scenario, cannot work absolute path. have use relative path.

"../assets/images/image.jpg" -this means

  1. '../' go 1 directory now
  2. find 'assets/' folder
  3. find 'images' folder
  4. find 'image.jpg' file.

that relative link work if page in subfolder in

"http://localhost/abc/def/geh/"

if location of page

"localhost/asdf/asdf/asdf/asdf/index.php"

(which seems ridiculous) assets folder relatively have go way root.

'../../../../abc/deh/geh/assets/images/image.jpg;

alternatively use base tag in head tag make url in actual src attribute more friendly.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -