Html 图像标签的 HTML5 验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7393392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML5 validation of image tags
提问by Francisc
Am I not allowed to specify the unit for width and height on <img>
tags in HTML5?
我不允许<img>
在 HTML5 中为标签指定宽度和高度的单位吗?
I am getting this error from the validator:
我从验证器收到此错误:
Bad value 122px for attribute width on element img: Expected a digit but saw p instead.
元素 img 上的属性宽度的错误值 122px:需要一个数字,但看到的是 p。
回答by George Cummins
Drop the 'px' part. Use only non-negative integers.
删除“px”部分。仅使用非负整数。
回答by Zain
Move the percentage width from the html tag to the in-line style:
将百分比宽度从 html 标签移动到行内样式:
For example:
例如:
Change this line
改变这一行
<iframe width="100%" height="588" style="border:none; background:transparent; overflow:hidden;" />
to this:
对此:
<iframe height="588" style="border:none; background:transparent; overflow:hidden; width:100%;" />
then it will validate...
然后它将验证...
回答by Shehzad Ahmed
just write 122 instead of 122p
只写 122 而不是 122p