Question about <img> tag properties.

Asked 2 years ago, Updated 2 years ago, 136 views

I get error verification through validator

Error: Bad value 48px for attribute width on element img: Expected a digit but saw p instead. dd>↩ <img src="images/additional-info-icon-warranty-mo.png" alt="" width="48px" > height="48px">↩

If you write the number px in the values of width and height, it is an error, but I wonder why this is an error.

And "Expected a digit but saw install." I wonder what this means.

fast-frontend validation img

2022-09-21 17:30

1 Answers

Hello, everyone Mr. Sung Jung-won :) It is yamu.

The width and height properties of the element you write in an HTML document do not use units because pixels are the default values. If it is not a pixel, it can be used with a unit value.

<img 
  src="http://image.zdnet.co.kr/2018/04/05/kunst_ddc8FxzPFEhv79.jpg"
  alt="A panoramic view of KEB Hana Bank's new headquarters in downtown Seoul." 
  width="620" 
  height="921">

<iframe
  width="560" 
  height="315" 
  src="https://www.youtube.com/embed/UMCw0ZgUYms" 
  allowfullscreen></iframe>

The IMG (Image) Element, W3C If you look at the documentation in earlier HTML3 versions, you will find: Pixels are the default values, so you don't need to attach units. HTML5 also appears to recommend removing pixel units.

WIDTH
    Set the width of the image (px(fixels) by default)
    Optional suggested width for the image. By default, this is given in pixels.


HEIGHT
    Set the image height (px (fixels) by default)
    Optional suggested height for the image. By default, this is given in pixels.

UNITS
    Optionally, the width, height property value can use units. en (half of point size)
    This optional attribute specifies the units for the width and height attributes. It is one of: units=pixels (the default) or units=en (half the point size).


2022-09-21 17:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.