简体   繁体   中英

How to put a image in HTML?

I am going to learn HTML. And I want to put my image from gallery to my web. How do I do that?

Please correct this code if I'm wrong because the image from my gallery is not displaying to my webpage.

Code:

<img src="/storage/emulated/0/DCIM/Camera/IMG_20190717_104912.jpg" alt=" "/ >

/storage/emulated/0/DCIM/Camera/IMG_20190717_104912.jpg looks like a file path on an Android phone; it's probably not right. If you end up deploying your HTML file at http://site.example/index.html then the browser will try to fetch http://site.example/storage/emulated/0/DCIM/Camera/IMG_20190717_104912.jpg which probably isn't your Android phone.

The best thing to do is to copy the image to the same place as your HTML file and then refer to it this way:

<img src="IMG_20190717_104912.jpg">

Here's a couple of other tips about your markup:

First, img is what's called a self-closing tag; you do not need to write /> at the end. You might see that sometimes in books from a period in the early 2000s where some people thought HTML might become an application of XML; that did not pan out. It is harmless to write /> but it is not useful so don't do it. (Note that if you do want to make your HTML be XML, I think you need to write /> with no space between them.) If you're learning HTML and see /> in it, try to find a more up-to-date resource to learn from.

Second, "alt" text is very useful to humans and machines, so use it; but if you have no useful content don't put a space in there—that's not useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM