HTML image
HTML Image
#<img> ; ->image image
<img src="url" alt="some_text">
<img src="../style/images/boat.gif" alt="Big Boat">
The image cannot be loaded in the browser At the same time, the replacement text attribute tells the reader the information they are missing. At this point, the browser will display this alternative text instead of the image.<img src="../style/images/pulpit.jpg" alt="Pulpit rock" width="300" height="200">
Tip: It is a good practice to specify the height and width of the image. If an image has a specified height and width, the specified dimensions will be retained when the page loads. If the size of the image is not specified, the overall layout of the HTML page may be destroyed when the page is loaded.Example
Add a background image:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body background="http://pic.58pic.com/58pic/15/97/99/27W58PICZS7_1024.jpg"> <h3>图像背景</h3> <p>gif 和 jpg 文件均可用作 HTML 背景。</p> <p>如果图像小于页面,图像会进行重复。</p> </body> </html>
Set the height and width of the image:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body > <img src="http://www.w3school.com.cn/i/eg_cute.gif" width="50" height="50"> <br /> <img src="http://www.w3school.com.cn/i/eg_cute.gif" width="100" height="100"> <br /> <img src="http://www.w3school.com.cn/i/eg_cute.gif" width="150" height="150"> </body> </html>