4

This question already has an answer here:

In both the preview and rendered question, this does not work:

<img src="http://i.stack.imgur.com/R7QBb.jpg" width="100px" height="100px">

..as the image doesn't appear (cleaned up by HTML sanitiser presumably):

It should be here → ← (click the edit button to see the source)

However, strangely omitting the px unit works:

<img src="http://i.stack.imgur.com/R7QBb.jpg" width="100" height="100">

..for example:

Here →

marked as duplicate by Shadow The Dragon Wizard, hims056, dbr, Mat, SudoRahul Mar 13 '14 at 12:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • (..image was from this related post) – dbr Mar 13 '14 at 11:56
  • 1
    According to W3C, height and width are supposed to contain non-negative integers. – Antony Mar 13 '14 at 11:56
  • @Antony Ohh, that explains it! For no justifable reason I thought the img width/height would accept things like 50% and so on - but that would explain it – dbr Mar 13 '14 at 11:58
  • The W3C validator also confirms what @Antony says: Bad value 100px for attribute width on element img: Expected a digit but saw p instead. Note that it is valid HTML 4, it's just invalid HTML 5. – Stijn Mar 13 '14 at 11:58
  • 2
    @dbr only CSS accepts units, not HTML attributes. :) – Shadow The Dragon Wizard Mar 13 '14 at 12:00
  • 4
    From the linked faq: width="" (up to 999; do not include the 'px' extension) – Shadow The Dragon Wizard Mar 13 '14 at 12:02