简体   繁体   中英

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. I thought removing the two 'p' tags would fix it but it still gives me the same error. 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. They just expect a number.

Link: 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. 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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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