Search code examples
cssinline-styles

Why does the element inspector show this div as having non-zero width?


In the code part of Chrome DevTools, we can see that the div's "width" attribute is set to 0px. But in the actual window, I can hover over it and it appears that the actual width is still 400 pixels.

Why?

Note that the div in question is #raphContainer2 (note the 2), not the one highlighted in blue in the Chrome DevTools.

What?


Solution

  • Because width isn't a valid attribute for your div, it should be embedded in style.

    Your code:

    <div id="raphContainer2" style="display" width="0px">
    

    How it should be:

    <div id="raphContainer2" style="display: block; width:0px">