diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js
index 8a689fe50..18a7f7027 100644
--- a/IPython/html/static/widgets/js/widget.js
+++ b/IPython/html/static/widgets/js/widget.js
@@ -611,7 +611,7 @@ define(["widgets/js/manager",
/**
* Makes browser interpret a numerical string as a pixel value.
*/
- if (/^\d+\.?(\d+)?$/.test(value.trim())) {
+ if (value && /^\d+\.?(\d+)?$/.test(value.trim())) {
return value.trim() + 'px';
}
return value;