Skip to main content Accessibility Feedback



Get the actual computed style of an element. This factors in browser default stylesheets as well as external styles you’ve specified.

var elem = document.querySelector('#some-elem');
var bgColor = window.getComputedStyle(elem).backgroundColor;

Works in all modern browsers, and IE9+. You can extend support back further with polyfills.