Using width/height without units in HTML5

Before HTML5, I use to set the width/height of an element through

element.style.width = 50
element.style.height = 100

and it used to consider 'px' as the default unit. After adding <!DOCTYPE html> all these are failing as I need to explicitly set the units while setting measurements. As I am using some of the libraries which used this style, its a lot of work to individually add 'px' to each of them. I am looking for a shim/polyfill to handle this automatically.


Thanks @Quentin.

We can't really use any shims/polyfill either since we are directly dealing with the DOM. Hence I greped the code for the pattern and fix them.

Answers


But adding px will give you a

Bad value (number)px for attribute height on element img: Expected a digit but saw p

if you put it into an HTML validator


Need Your Help

Django + trac-wiki to html markdown 'SafeText' object has no attribute 'get'

python django django-templates trac wiki-markup

I am trying to render trac wiki markdown format as html for display on my website. I tried following this other SO question 'how do i use trac wiki formatting', but the code snippet returns an erro...

Sqlalchemy create a database table manually

python postgresql sqlalchemy

Is there a way to create a table without using Base.metadata.create_all(). I'm looking for something like Mytable.create() which should create only its corresponding table.