How to fix: Bad value 180px for attribute width on element img: expected a digit but saw p instead.

Most Likely Cause and Fix

In the context of <img width="180px" /> the attribute width is not allowed to take the value 180px.

You should remove this attribute or set a valid value for your markup to be considered valid.

What This Error Means

Some element attributes can take pretty much any value, others can take only values of a certain type and others still can only take a value from a pre-defined set.

This error relates to the following usage in your markup:

<img width="180px">

The error is stating that, in this context, the attribute width on element img is not allowed to take the value 180px

The validator is giving the reason: expected a digit but saw p instead.

How To Fix It

The error relates to an invalid attribute value being used on a specific element.

How this might be fixed often depends on the element, attribute, attribute value and the context in which these are being used.

Pay attention to the additional information supplied by the HTML validator as this will often point you in the right direction: expected a digit but saw p instead.

In general

Change the relevant attribute value to one that is valid for the context in which it is being used.

Discuss, Comment and Improve

Did this help you? Can this page be improved? Let us know!

comments powered by Disqus