HTML中的
src
属性指定嵌入式资源的位置,最常见的图像,但也适用于音频,视频和iFrames。 此位置可以相对于当前网页,相对于服务器的根目录,也可以是完整的URL。
相对路径:
<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/174052993373573.jpg" class="lazy" alt="src (HTML attribute) ">
<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/174052993391833.jpg" class="lazy" alt="src (HTML attribute) ">
在网站root:<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/174052993464780.jpg" class="lazy" alt="src (HTML attribute) ">
/images
绝对URL:对于托管在其他服务器上的图像,请使用完整的URL:
<img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/174052993538767.jpg" class="lazy" alt="Image Description">
的映像:
myimage.png
<code class="language-html"><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/174052995196248.png" class="lazy" alt="src (HTML attribute) "></code>
属性:
alt
> 属性应准确反映文件类型(例如,alt
,src
,.jpg
)。.png
)。
.gif
> .mp4
错误处理:.mp3
如果找不到指定的资源,浏览器通常会显示损坏的图像图标或根本没有显示。 适当的错误处理可能涉及替代图像源或后备机制。>提供的文本涵盖了属性的许多方面,这是一个简洁的摘要,解决了要点:
>src
?src
src
>哪些标签使用?<img alt="SRC(HTML属性)" >
<audio></audio>
,<video></video>
,<iframe></iframe>
,src
>如果缺少会发生什么?
src
多个源?>在<source></source>
<picture></picture>
标签。<audio></audio>
>
<video></video>
>src
href
src
embedscontent; href
链接
以上是SRC(HTML属性)的详细内容。更多信息请关注PHP中文网其他相关文章!