影像 <img>
<img> 可在 HTML 中,引入所需之影像。從技術上來說,圖像並未插入網頁中,而是建立一個影像的區域。藉由 src 的屬性指定影像的來源位置,才能將影像渲染在網頁上。
html
<img src="./images/logo.png" width="300" height="50" alt="Logo" title="商標" loading="lazy">src
影像來源位置。
html
<img src="./images/logo.png">width
定義影像渲染在網頁所需的寬度。
html
<img width="300">height
定義影像渲染在網頁所需的高度。
html
<img height="50">alt
定義影像遺失時,所顯示的替代文字。
html
<img alt="Logo">title
定義游標懸浮在影像上所出現的提示文字。
html
<img title="商標">loading
當影像需要顯示在使用者視線之前,才去動態載入影像。
html
<img loading="lazy">