What is element.style and why is it overriding my css settings?

I have a popup that comes up over a blanket div that greys out the entire screen, but I don't like its positioning. So I tried to manually enter left: and top: elements into my CSS, but when I look at Chrome's console, there's this element.style {} that's overriding my code.

I've searched my CSS file for element.style and for 597px and 794px and I don't get hits on any of them.

What is this, and why does it have the values that it has?

enter image description here

4 Answers

element.style is a part of your browser devtools that indicates the inline style of the element which has a higher specificity value than any CSS selectors.

That inline styles may be added by a JavaScript code, if so, you can override that declarations by using !important keyword within your stylesheet (e.g. left: 610px !important).

1

element.style refers to inline styles on the dom element. For example:

<p>Foo</p>

the color of that paragraph would show up under element.style.

You can fix with your css by doing this:

#popUpDiv[style]{ left:610px !important; top:0px !important;
}

HTH -Ted

That's probably manipulated and set by javascript (either that or you edited the element.style{} rule yourselves on the developer tools console).

Look for javascript code that changes the display, top and left properties of #popupDiv

It is the style that you have in the HTML file. try to delete or change the style in HTML.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like