Search code examples
htmlimagesrcalt

img src doesn't find image, prints alt


<img src=“…/images/adam_photo.jpg” alt=“don't_print_this_damnit” />

Displays “don't_print_this_damnit”

web file located:

file:///Users/Adam/Documents/adam_webfolder/adam_webfile.html

image located:

file:///Users/Adam/Documents/adam_webfolder/images/adam_photo.jpg

I don't understand why this isn't working.


Solution

  • You are using correct quotation marks! (, )

    (Unfortunately), correct quotes in the english language aren't correct in the Hypertext Markup Language or pretty much every other markup or programming language. Use the neutral ".

    Also, you are using the ellipis character () instead of three dots (...).

    You're using an office writer program to write your code, am I right? Programs like Word or OpenOffice are wonderful for writing articles, books, etc., but they aren't designed for coding, because they replace some characters automatically for you. Use one of the great text editors especially made for coding out there, like Atom, Sublime Text or Visual Studio Code to work with HTML, CSS and JavaScript.


    UPDATE: Of course, three dots aren't correct either and won't work, I think. Try two dots to move up one directory and one dot to stay in the directory you are currently. In this case, removing the point and the slash is even shorter:

    And finally, here is your fixed img element (Although, I don't know if the path is right.):

    <img src="./images/adam_photo.jpg" alt="dont_print_this_damnit" />
    // OR:
    <img src="images/adam_photo.jpg" alt="dont_print_this_damnit" />
    

    For more info about these dot notations, check this nice article:

    https://css-tricks.com/quick-reminder-about-file-paths/