简体   繁体   English

如何验证此html?

[英]How do I validate this html?

I designed a website for a company and everything works great. 我为一家公司设计了一个网站,并且一切正常。 I decided that i might as well validate the whole thing so Ive been crushing errors. 我决定我最好还是验证整个事情,所以我一直在消除错误。 However, I came across this problem that I can't seem to figure out. 但是,我遇到了一个似乎无法解决的问题。
here is the error 这是错误

Line 86, Column 106: Bad value 105px for attribute height on element img: Expected a digit but saw p instead.

Line 86, Column 106: Bad value 216px for attribute width on element img: Expected a digit but saw p instead.


Here is the line 这是线

<p class="centeredImage"><img src="images/logo.png" height="105px" width="216px" alt="ATS Logo"><img src="images/header1.png" alt="ATS Header"></p>


I am using the p class of centeredImage to obviously center the two images in the div. 我正在使用centeredImage的p类将两个图像显然放在div中。 I thought removing the two 'p' tags would fix it but it still gives me the same error. 我以为删除两个'p'标签会解决它,但仍然给我同样的错误。 It seems to be a problem with the actual height and width attributes. 实际的高度和宽度属性似乎有问题。

Can someone tell me what is going on here and how to fix it? 有人可以告诉我这里发生了什么以及如何解决?

The width and height attributes have nothing to with CSS. widthheight属性与CSS无关。 They just expect a number. 他们只是期待一个数字。

Link: http://www.w3.org/wiki/HTML/Elements/img 链接: http//www.w3.org/wiki/HTML/Elements/img

Height and with are by default expressed in px adding " px " to the value makes a validation error. 身高与默认情况下在PX表示加入“PX”到设定值,使验证错误。 You should write your tag like: 您应该这样写标签:

<img src="images/logo.png" height="105" width="216" alt="ATS Logo">

The height and width is interpreted as pixels. 高度和宽度被解释为像素。 If you require the width or height as percent of space is necessary to add "%" after the numbers. 如果您需要宽度或高度作为空间的百分比,则必须在数字后添加“%”。

height和width属性不需要“ px”即可http://www.w3schools.com/tags/att_td_height.asp

u have used 你用过

height="105px" width="216px"

whereas it should be 而应该是

height="105" width="216"

don't use px there.. 不要在那里使用px。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM