Why won't my image show in HTML?

社会主义新天地 提交于 2019-12-12 03:35:55

问题


I'm having issues with getting an image to display on my HTML page. I currently have "image.png" in the same folder as the .html file and it still won't work. I am using Chrome btw. Here is my code:

<!DOCTYPE html>

    <head>
        <title> Title </title>
    </head>

    <body>
        <h1> This is an image </h1>
        <img src = “image.png” alt = “Image text”/>

    </body>

</html>

回答1:


You seem to be using smart quotes. You need to use normal ones.

Replace with '"' and with "

<img src = "image.png" alt = "Image text"/>

You should use a Programming Editor like Notepad++ or Sublime Text, since they do not convert quotes into smart quotes

Also not that you are missing the opening <html> tag




回答2:


You should be using standard quotation marks, e.g. " ". So:

<img src = "image.png" alt = "Image text"/>



回答3:


Is it in a folder inside the root folder? Also use "".

<img src="image.png" alt="image text" style="width:100px;height:100px;">



回答4:


Looks like the editor you're using is applying some form of character encoding that's messing with your script, Notice how your quotation marks are slanted? What editor are you using?

The best way to fix this is to either put your code into Notepad (if you're on windows) and retype your quotation marks to remove the character encoding or configure your editor to use the correct encoding (Usually UTF-8)



来源:https://stackoverflow.com/questions/36012493/why-wont-my-image-show-in-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!