Why is it not a good idea to constrain images using the widt

Why is it not a good idea to constrain images using the width and height attributes of the img tag? What is a better approach?.

Solution

I will conflict with the grain here and express that the guideline of isolating substance from format (which would legitimize the appropriate responses that recommend utilizing CSS) does not generally apply to picture height and width.

Each picture has an intrinsic, unique height and width that can be gotten from the picture information. In the structure of substance versus design, I would state this determined height and width data is content, not format, and ought to along these lines be rendered as HTML as component characteristics.

This is much similar to the alt content, which can likewise be said to be gotten from the picture. This additionally underpins the possibility that a self-assertive client operator (e.g. a discourse program) ought to have that data so as to relate it to the client. In any event, the angle proportion could demonstrate valuable (\"picture has a width of 15 and a stature of 200\"). Such client operators wouldn\'t really handle any CSS.

The spec says that the width and stature properties can likewise be utilized to abrogate the height and width passed on in the genuine picture record. I am not proposing they be utilized for this. To abrogate height and width, I trust CSS (inline, implanted or outer) is the best approach.

So relying upon what you need to do, you would indicate one or potentially the other. I think preferably, the first height and width would dependably be determined as HTML component characteristics, while styling data ought to alternatively be passed on in CSS.

Determining the picture measurements by means of CSS ought to be similarly useful for holding space, with the questionable advantages that you don\'t need to indicate two presentational qualities and that you may diminish markup bloat to some degree.

There might be issues with some antiquated programs, however I don\'t think they merit agonizing over. IIRC, old Netscape renditions wouldn\'t stack more than 4 pictures in parallel if the measurements weren\'t hardcoded into the markup.

I never utilize the width and tallness properties for pictures any more. I utilize CSS.

Thank you.

Why is it not a good idea to constrain images using the width and height attributes of the img tag? What is a better approach?.SolutionI will conflict with the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site