Can’t get ‘width’ attribute of an element with JS

I can’t get the ‘width’ attribute of an element:

    <div class="container" width="55"> 


This returns “undefined”, other attributes like “id” I can get this way, but not width and height. I find this problem so silly, why doesn’t it work? Even here they write it should work:

I don’t need any workarounds like with jQuery or outerWidth, etc. I just need to get the width and height attributes from the element.

Edit: My actual problem is with SVG element, but with DIV it also doesn’t work.


You are looking for Element.getAttribute() (Documentation)

<div class="container" width="55"></div>