img在html中不是雙標簽元素。img標簽是一種單標簽,用于定義HTML頁面中的圖像。img標簽有兩個必需的屬性,分別是src屬性和alt屬性。
本文操作環(huán)境:windows10系統(tǒng)、html 5、thinkpad t480電腦。
在html中,<img>標簽是單標簽。
標簽介紹:
<img> 標簽定義 HTML 頁面中的圖像。
<img> 標簽有兩個必需的屬性:src 和 alt。
常用屬性:
-
alt text 規(guī)定圖像的替代文本。
-
height pixels 規(guī)定圖像的高度。
-
src URL 規(guī)定顯示圖像的 URL。
-
width pixels 規(guī)定圖像的寬度。
代碼示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(php.cn)</title> </head> <body> <img src="smiley-2.gif" alt="Smiley face" width="42" height="42"> </body> </html>
(免費視頻教程:html視頻教程)
運行結果: