HTML 属性 'alt' 是否适用于数字?
Does HTML attribute 'alt' work with numbers?
在此 example 中,alt 属性的值在包含数字之前不会显示。所以,这条线不起作用:
<img src="non-existent.jpg" alt="W3Schools.com" width="104" height="142">
但是那个有效:
<img src="non-existent.jpg" alt="WSchools.com" width="104" height="142">
你能解释一下为什么吗?
我使用 Google Chrome 和 Windows 8.1。提前谢谢你。
alt 中存在的字符串仅在图像加载失败或不可用时显示。即使有数字,alt 也会显示它。
你说的不显示是在一种情况下
If the text fits the width of the image, it will be displayed, else it
will not be visible.
您提供的两个代码都有效。
<img src="non-existent.jpg" alt="W3Schools.com" width="104" height="142"> // works
<img src="non-existent.jpg" alt="WSchools.com" width="104" height="142"> // works
<img src="non-existent.jpg" alt="W3535Schools.com" width="104" height="142"> //works
看看这个
在此 example 中,alt 属性的值在包含数字之前不会显示。所以,这条线不起作用:
<img src="non-existent.jpg" alt="W3Schools.com" width="104" height="142">
但是那个有效:
<img src="non-existent.jpg" alt="WSchools.com" width="104" height="142">
你能解释一下为什么吗?
我使用 Google Chrome 和 Windows 8.1。提前谢谢你。
alt 中存在的字符串仅在图像加载失败或不可用时显示。即使有数字,alt 也会显示它。
你说的不显示是在一种情况下
If the text fits the width of the image, it will be displayed, else it will not be visible.
您提供的两个代码都有效。
<img src="non-existent.jpg" alt="W3Schools.com" width="104" height="142"> // works
<img src="non-existent.jpg" alt="WSchools.com" width="104" height="142"> // works
<img src="non-existent.jpg" alt="W3535Schools.com" width="104" height="142"> //works
看看这个